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

Multipart upload with ActionDispatch::Http::UploadedFile TempFile uses wrong filename #597

Closed
zherr opened this issue Jul 2, 2018 · 2 comments

Comments

@zherr
Copy link
Contributor

zherr commented Jul 2, 2018

Hello!

We're seeing an issue where a TempFile used with an ActionDispatch::Http::UploadedFile is resulting in the filename= of the multipart body using the randomly generated filename of the Tempfile instead of the original_filename.

For example:

filename = 'test.txt'
tempfile = Tempfile.open(filename) # creates /var/folders/sm/f8vxq1813p3913nwj9_qh7xs6js3gp/T/test.txt20180702-40300-7o0g19
upload = ActionDispatch::Http::UploadedFile.new(tempfile: tempfile, filename: filename)
upload.original_filename # => "test.txt" desired result
File.basename(upload.path) # => "test.txt20180702-40300-dyj4fd" actual result

Apparent root cause: https://github.com/jnunemaker/httparty/blob/master/lib/httparty/request/body.rb#L37

@zherr zherr changed the title Mulipart upload with ActionDispatch::Http::UploadedFile TempFile uses wrong filename Multipart upload with ActionDispatch::Http::UploadedFile TempFile uses wrong filename Jul 2, 2018
@mikeelltt
Copy link

Having the same issue, will the PR be merged? 🙏

@zherr
Copy link
Contributor Author

zherr commented Jul 9, 2018

I hope so! @jnunemaker, do you have a few moments to review this issue and solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants