Forum: Ruby Writing an image to file

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
marcus (Guest)
on 2006-02-08 08:00
(Received via mailing list)
I have images stored in a database. I now need to read those images from
the database and store to files (using ActiveRecord in a system where
$KCODE = 'u'; require 'jcode' is used (if that matters...)).

I've tried a couple of approaches but it's only giving me destroyed
images (when served to a browser using webrick they look perfectly

I've tried:

     str_bin = "" do |b|
       str_bin << b
     end"public/published/#{}", "w") do |file|
       file.print str_bin

and"public/published/#{}", "w") do |file|

and"public/published/#{}", "w") do |file|

All with the exact same result.

I suppose there must be a simple way to solve this?


Matthew M. (Guest)
on 2006-02-08 08:06
(Received via mailing list)
Does using "wb" instead of "w" in make a difference?
marcus (Guest)
on 2006-02-08 08:06
(Received via mailing list)
Yep, that worked. Thank you very much.


Matthew M. skrev:
Raveendran .. (Guest)
on 2009-04-20 13:55
Hi All,

Get all images from given URL

Desktop Application from jazzez

Kindly go through below link and download the EXE file.

Install in Windows machine and enjoy with impressed images

This topic is locked and can not be replied to.