Can I use ruby rest-client to POST a binary file to an http API?
Posted
by Angela
on Stack Overflow
See other posts from Stack Overflow
or by Angela
Published on 2010-05-22T01:26:55Z
Indexed on
2010/05/22
1:30 UTC
Read the original article
Hit count: 422
rest-client
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
© Stack Overflow or respective owner