Can I use ruby rest-client to POST a binary file to an http API?
- by Angela
I have been using rest-client in ruby in post XML to a third-party API.
I need to be able to include a binary image that's uploaded.
How do I do that?
Uploading Attachments
Both letters and postcards will, in
most cases, require the attachment of
documents. Those attachments might be
PDFs in the case of letters or images
in the case of postcards.
To uploading an attachment, submit a
POST to:
http://www.postful.com/service/upload
Be sure to include the Content-Type
and Content-Length headers and the
attachment itself as the body of the
request.
POST /upload HTTP/1.0 Content-Type:
application/octet-stream
Content-Length: 301456
... file content here ...
If the upload is successful, you will
receive a response like the following:
290797321.waltershandy.2