how do I base encode a binary file (JPG) in ruby

Posted by Angela on Stack Overflow See other posts from Stack Overflow or by Angela
Published on 2010-06-08T04:40:14Z Indexed on 2010/06/08 4:42 UTC
Read the original article Hit count: 248

Filed under:
|
|

I have a binary files which needs to be sent as a string to a third-party web-service. Turns out it requires that it needs to be base64 encoded.

In ruby I use the following:

 body = body << IO.read("#{@postalcard.postalimage.path}")

body is a strong which conists of a bunch of strings as parameters.

So...how do I base64 encode it into this string?

Thanks.

© Stack Overflow or respective owner

Related posts about ruby

Related posts about binary