Skip to content


file upload support to make http fun #77

timwaters opened this Issue · 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.







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


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.


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


+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

The dependency works the other way around now.


I know this issue is fairly old, but it ranks highly in Google searches, so I thought I should update. jwagener/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/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'


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.