httparty icon indicating copy to clipboard operation
httparty copied to clipboard

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

Open zherr opened this issue 8 years ago • 2 comments

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 avatar Jul 02 '18 19:07 zherr

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

mikeelltt avatar Jul 09 '18 11:07 mikeelltt

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

zherr avatar Jul 09 '18 11:07 zherr