1
0
Fork 0
mirror of https://github.com/jnunemaker/httparty synced 2023-03-27 23:23:07 -04:00

Support ActionDispatch::Http::UploadedFile again

Using the `path` method instead of passing the file directly to
`File.basename` to get the filename ensures that
`ActionDispatch::Http::UploadedFile` can be used again.

Related issue: https://github.com/jnunemaker/httparty/issues/584
This commit is contained in:
Maarten Claes 2018-03-27 15:07:21 +02:00
parent db8df8c58b
commit 0719036378
2 changed files with 5 additions and 1 deletions

View file

@ -1,3 +1,7 @@
## Unreleased
* [Support ActionDispatch::Http::UploadedFile again](https://github.com/jnunemaker/httparty/pull/585)
## 0.16.1
* [Parse content with application/hal+json content type as JSON](https://github.com/jnunemaker/httparty/pull/573)

View file

@ -32,7 +32,7 @@ module HTTParty
multipart = normalized_params.inject('') do |memo, (key, value)|
memo += "--#{boundary}\r\n"
memo += %(Content-Disposition: form-data; name="#{key}")
memo += %(; filename="#{File.basename(value)}") if file?(value)
memo += %(; filename="#{File.basename(value.path)}") if file?(value)
memo += "\r\n"
memo += "Content-Type: application/octet-stream\r\n" if file?(value)
memo += "\r\n"