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

getting full file name from parsing FormData payloads #2244

Closed
jimmywarting opened this issue Sep 3, 2023 · 3 comments · Fixed by #2245
Closed

getting full file name from parsing FormData payloads #2244

jimmywarting opened this issue Sep 3, 2023 · 3 comments · Fixed by #2245
Labels
bug Something isn't working

Comments

@jimmywarting
Copy link
Contributor

jimmywarting commented Sep 3, 2023

Bug Description

Reproducible By

var fd = new FormData()
var f = new File(['abc'], 'folder/readme.md', { type: 'text/plain' })
fd.set('x', f)
new Response(fd).formData().then(fd => fd.get('x').name).then(console.log)

Expected Behavior

To log folder/readme.md

Logs & Screenshots

actual output: readme.md

Environment

  • Darwin 22.4.0 arm64 arm
  • NodeJS v20.2.0

Additional context

  • All browser (including Deno & node-fetch) returns the full filename.
  • constructing a File that includes / is totally fine. new File(parts, 'dumm/di/dumm.txt')

i guess why the hole reason why this is even supported is b/c browser have been able to use

<input type=file webkitdirectory>

then when you select some folder, and upload them all the content-disposition would then be:

Content-Disposition: form-data; name="files"; filename="folder/readme.md"

busboy have this preservePath option... would like for you to set it to true

@jimmywarting jimmywarting added the bug Something isn't working label Sep 3, 2023
@jimmywarting jimmywarting changed the title getting full filename from parsing FormData payloads getting full file name from parsing FormData payloads Sep 3, 2023
@KhafraDev
Copy link
Member

busboy have this preservePath option... would like for you to set it to true

would you like to send in a PR?

@jimmywarting
Copy link
Contributor Author

Sure.

@titanism
Copy link
Contributor

awesome @jimmywarting 🙏 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants