Search code examples
rubyrestoauthoauth-ruby

Ruby Oauth File upload/Multipart POST request


I've been looking at this for a couple of days now and haven't found a solution. Is there a way to upload a file using OAuth-Ruby?

I am working with a REST system that protects their resource with oauth. I am building a test tool using ruby and oauth-ruby to make it easier to upload test data to the system. But I can't get around to upload files to the resources.

When I send a normal request, everything works but adding a file as a parameter makes the signature invalid.

Example:

 @access_token.post("http://.../imageresource", {:name=>"awesome cat"}, {'Content-Type' => 'multipart/form-data'})

works but gives me:

 <error>
    <message>images/POST: Request has no file data</message>
 </error>

I am not sure how to add a file to the post.

Any thoughts on this?

Thanks,


Solution

  • I know this is old but I'm looking to do this too, this looks like it could do the trick.

    Actually there's a question ruby-how-to-post-a-file-via-http-as-multipart-form-data that has an example.