From: "Abinoam Jr." Date: 2012-02-14T06:03:25+09:00 Subject: Re: How do I save a Net::BER::BerIdentifiedString as a binary file? Net::BER::BerIdentifiedString is just a string with a ber indentifier attached. Source: http://net-ldap.rubyforge.org/Net/BER/BerIdentifiedString.html (no matter what stands for 'ber'). So, you should know how the .jpg is being encoded inside the String! Strings are not just a sequence of bytes (See character encoding) Is it Base64 encoded? You can try to Marshal.dump the object and see if somebody can guess. File.open("ber_jpeg_file.dump", 'w') {|f| f.write Marshal.dump(your_ber_object) } Abinoam Jr. On Mon, Feb 13, 2012 at 6:23 AM, Robert Klemme wrote: > On Fri, Feb 10, 2012 at 11:18 PM, Edward Stembler wrote: >> Anyone know how to save a Net::BER::BerIdentifiedString as a binary >> file? >> >> I've tried .dump, but that did not work.  I noticed there's a .bytes >> enumerator, but I'm not sure what to do with it. >> >> Basically, I have an Net::BER::BerIdentifiedString [Binary Data] which >> is holding a profile photo from an LDAP call, and I want to save it as a >> jpg file. > > File.open 'foo.jpg', 'wb' do |io| >  io.write bytes > end > > Something like that. > > Kind regards > > robert > > > -- > remember.guy do |as, often| as.you_can - without end > http://blog.rubybestpractices.com/ >