Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

German umlauts in file names are encoded when uploading via server action form data #70147

Closed
CombeeMike opened this issue Sep 16, 2024 · 2 comments
Labels
bug Issue was opened via the bug report template. create-next-app Related to our CLI tool for quickly starting a new Next.js application. locked Runtime Related to Node.js or Edge Runtime with Next.js.

Comments

@CombeeMike
Copy link

CombeeMike commented Sep 16, 2024

Link to the code that reproduces this issue

https://github.com/CombeeMike/nextjs-server-actions-form-data-upload-with-umlauts-demo

To Reproduce

  1. Start app with npm run dev

  2. Navigate to http://localhost:3000

  3. Upload file with umlauts in name (e.g. aäaÄaöaÖaüaÜaßa.pdf)

  4. 🔥 Server logs Received file name "aäaÃ�aöaÃ�aüaÃ�aÃ�a.pdf". See server.actions.ts:submitFormAction.

Current vs. Expected behavior

Server should receive file names as transmitted from client. aäaÄaöaÖaüaÜaßa.pdf vs aäaÃ�aöaÃ�aüaÃ�aÃ�a.pdf.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP Fri Mar 29 23:14:13 UTC 2024
  Available memory (MB): 15923
  Available CPU cores: 8
Binaries:
  Node: 20.10.0
  npm: 10.2.3
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 15.0.0-canary.156 // Latest available version is detected (15.0.0-canary.156).
  eslint-config-next: N/A
  react: 19.0.0-rc-206df66e-20240912
  react-dom: 19.0.0-rc-206df66e-20240912
  typescript: 5.3.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

create-next-app, Runtime

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), next start (local)

Additional context

No response

@CombeeMike CombeeMike added the bug Issue was opened via the bug report template. label Sep 16, 2024
@github-actions github-actions bot added create-next-app Related to our CLI tool for quickly starting a new Next.js application. Runtime Related to Node.js or Edge Runtime with Next.js. labels Sep 16, 2024
@CombeeMike CombeeMike changed the title German umlauts are in file names are encoded when uploading via server action form data German umlauts in file names are encoded when uploading via server action form data Sep 16, 2024
@nathanielrich
Copy link

Hi CombeeMike,

this is a common "error" by file uploading with nodejs...

you can fix it easy with this snipped:

const name = Buffer.from(file.name, 'latin1').toString('utf8');

Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. create-next-app Related to our CLI tool for quickly starting a new Next.js application. locked Runtime Related to Node.js or Edge Runtime with Next.js.
Projects
None yet
Development

No branches or pull requests

2 participants