-
Notifications
You must be signed in to change notification settings - Fork 321
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
API to post file #73
Comments
Or possibly an API like |
@tarcieri Yes, that would be nice. FYI, I’ve been working on replacing Faraday with the HTTP gem on a branch in the Twitter gem. I’ve got pretty much everything working except for posting files (this branch also depends on JSON parsing, which I’ve hacked together in a local branch). |
Nice, someone actually pinged me on Faraday support for the HTTP gem yesterday |
That would be nice too. I haven’t done proper benchmarking but the Twitter test suite (about 900 examples that make about 368 HTTP requests) runs about 4X faster in the I’d be curios to see how the performance would compare using an HTTP gem adapter for Faraday. I suspect it would be slower than using just the HTTP gem (sans Faraday). I think Faraday’s slowness is a result of having a middleware stack that each request must pass through. I do think writing a Faraday adapter would make it easier for people to try the HTTP gem in their existing clients. |
https://github.com/nicksieger/multipart-post actually looks like it can be used anywhere. |
I don't think this is required for 0.6 |
I agree, this is more of a nice-to-have for v0.6 but I think it’s a requirement for v1.0. |
I’ve moved this issue out of the v0.6 milestone and created a new v1.0 milestone. |
Seems good |
An issue with HTTP.post(url, :form => {
:title => "Foobar",
:file => HTTP::UploadIO.new(path_to_file, optional_mime_type)
}) Something very similar to Faraday actually ;)) |
@ixti That would be acceptable to me. What is needed to support this? |
@sferik I guess some spare time ;)) Other than that I don't see any problems here :D |
@ixti 👍 |
@Asmod4n multipart-post uses @ixti I’ve merged the |
@sferik will try to jimp on this during this weekend. |
@ixti \o/ |
@ixti 👍 |
@sferik what i was trying to say was multipart-post looks like it doesn't depent on anything and can be injected into any IO library, namely https://github.com/nicksieger/multipart-post/blob/master/lib/parts.rb seams to be independent of Net::HTTP and can be hooked into this gem :) |
@Asmod4n Ah, very nice. :) |
I have started working on this issue, but not yet finished :D Will finish during this week. |
@ixti Awesome! If this code is independent of the |
@sferik Makes sense. Although I would like to first build it as part of HTTP gem - and then simply extract those classes out :D Re suggested name. Actually a more appropriate name will be # Usage inside with HTTP Gem:
HTTP.post(some_url, :form => {
:username => "ixti",
:avatar => HTTP::FormData::File.new("/path/to/file.jpg"),
:cv => HTTP::FormData::File.new(io, :filename => "cv.pdf")
})
# Standalone usage:
form = HTTP::FormData.new({
:username => "ixti",
:avatar => HTTP::FormData::File.new("/path/to/file.jpg"),
:cv => HTTP::FormData::File.new(io, :filename => "cv.pdf")
})
form.to_s # => returns HTTP request multipart body |
@ixti The above is really helpful. It would be even more helpful if it's in the README of the gem. Thank you. |
@zackxu1 it's documented here: https://github.com/httprb/http/wiki/Passing-Parameters |
I’m trying to perform a multipart
POST
with the HTTP gem but I’m having trouble getting the headers and body right. We should include an example of how to do this in theREADME
.The text was updated successfully, but these errors were encountered: