From: Belorion Date: 2005-01-07T01:36:44+09:00 Subject: Re: Image decompression, eruby On Fri, 7 Jan 2005 01:24:36 +0900, Roland Schmitt wrote: > Hi, > you can try to convert the binary data to base64 and then store the > base64-data in the database: > > require "base64" > ... > b64_data = Base64.encode64(binary_data) > # store to db > ... > # read from db > binary_data = Base64.decode64(b64_data) > ... > > Obviously you must convert back after reading the data from the database > ;-) > > For me base64-formatted data is easier to handle when looking for > differences between two files. > > Regards, > Roland I've tried that once with no success, but maybe I'll give it a shot again. Although, it occurrs to me... my "test" which told me my MySQL data was bad may have been incorrect. What, precisely, is the best/correct way to write out binary data? Basically, what I was doing was: sth = dbh.prepare( "SELECT content FROM attachment WHERE index=41" ) sth.execute data = sth.fetch[0] f = File.new( "test.jpg", "w+" ) f << data f.close Is that correct way to write out binary data?