jnunemaker / httparty

:tada: Makes http fun again!
MIT License
5.8k stars 963 forks source link

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

Closed zherr closed 6 years ago

zherr commented 6 years ago

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

mikeelltt commented 6 years ago

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

zherr commented 6 years ago

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