-
Notifications
You must be signed in to change notification settings - Fork 324
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
Add multipart/form-data support #167
Conversation
@ixti Am I missing something? Where is |
@sferik it's not ready yet - work in progress :D |
@sferik pushed a patch with api draft. With 99% confidence it will stay as it is -- only internals will be implemented properly. FormData::File might get splitted into IO and File actually. |
c42a794
to
dfd8f6a
Compare
Finally! I've did it!!! :D Moved # Usage inside with HTTP Gem:
HTTP.post(some_url, :form => {
:username => "ixti",
:avatar => FormData::File.new("/path/to/file.jpg"),
:cv => FormData::File.new(io, :filename => "cv.pdf")
})
# Standalone usage:
form = FormData.create({
:username => "ixti",
:avatar => FormData::File.new("/path/to/file.jpg"),
:cv => FormData::File.new(io, :filename => "cv.pdf")
}) @sferik, @tarcieri I have avoided |
42760a7
to
7dc5f13
Compare
Notice that FormData.create({
:foo => { :bar => "baz" }
}).to_s
# => foo[bar]=baz
FormData.create({
:foo => { :bar => "baz" },
:img => FormData::File.new("/home/ixti/avatar.png")
}).to_s
# =>
# --boundary
# Content-Disposition: form-data; name="foo[bar]"
#
# baz
# --boundary
# Content-Disposition: form-data; name="img"; filename="avatar.png"
# Content-Type: application/octet-stream
#
# ...
# --boundary-- |
Revealed and fixed Transfer-Encoding double entry
7dc5f13
to
1021211
Compare
LGTM 👍 |
Add multipart/form-data support
Resolves #73