Skip to content

file upload support to make http fun #77

timwaters opened this Issue Mar 14, 2011 · 16 comments

Pretty much every ruby http library does not support file uploads. This is wrong, and leads people to write their own libraries, scripts, subroutines and hacks, often failing.

Httparty, being the best http library should support this.

Please make http fun, and support file uploads.


lou commented Apr 28, 2011


mickey commented Apr 28, 2011



It is open source... sounds like a perfect time for you to jump in.

mickey commented Apr 28, 2011

Hey Matt,
You perfectly right on this one,
I actually saw there's some good parts that could be use for a great file upload support :

I already have a prototype working locally with some part here and here + some patches, I'll try to add a good testing suite and make a pull request for review.


@mickey it's really great to hear you want to take that on!


As a quick FYI for those wondering about this, I've monkey-patched basic support of #body_stream with the following:

module HTTParty
  class Request

    def setup_raw_request
      @raw_request =
      if body
        if body.respond_to?(:read)
          @raw_request.body_stream = body
          @raw_request.body = body
      @raw_request.basic_auth(username, password) if options[:basic_auth]
      setup_digest_auth if options[:digest_auth]


If you give :body an IO object, this will pick that up and run a streaming push instead of raw file data.

maletor commented Feb 16, 2012

Yes this is good. A little test and this should be good to go.

rtdp commented Feb 21, 2012

+1 to file upload support




If this requires another dependency, I'd rather see it done as a plugin in a separate gem. I'm happy to add hooks and such if that is what is needed. Closing this for now.

@jnunemaker jnunemaker closed this Apr 22, 2012
maletor commented Apr 22, 2012

The dependency works the other way around now.

radar commented Mar 21, 2014

I know this issue is fairly old, but it ranks highly in Google searches, so I thought I should update. jwagener-soundcloud/httmultiparty#11 indicates that while the file upload features of the library work, it falls apart when you want to pass more parameters than just the file that's being uploaded. I addressed this in jwagener-soundcloud/httmultiparty#30.

If @jwagener doesn't merge this due to whatever reason, I'm happy to maintain a fork of that library on my personal GitHub.

gem 'httmultiparty', github: 'radar/httmultiparty', branch: 'master'
narzero commented Jul 28, 2014




Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.