Skip to content

Commit

Permalink
Support ActionDispatch::Http::UploadedFile again
Browse files Browse the repository at this point in the history
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: #584
  • Loading branch information
mcls committed Mar 27, 2018
1 parent db8df8c commit 0719036
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/httparty/request/body.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def generate_multipart
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"
Expand Down

0 comments on commit 0719036

Please sign in to comment.