On Wednesday, August 8, 2012 2:37:43 AM UTC-7, BigDav Huang wrote:
>
> Hello all
>
> Problem happens when I try to extract blob data into JPG file.
>
> Here is my code:
>
> fb_table = DB[:feedbacks]
> feedbacks = fb_table.where('updated_at IS NULL')
> feedbacks.each{ |_feedback|
> File.open(_feedback[:id].to_s+".jpg", 'w') {|f|
> f.write(_feedback[:attachment]) }
>
> }
>
> When I open the files I saved, they seem damaged. However the files look
> fine if I extract them by Firefox SQLite Manager plugin.
>
> I am using JRuby 1.6.7 and Sequel 3.38.0
>
> Can anyone help?
>
You may want to try using 'wb' instead of 'w' when writing the file.
Beyond that, I have no idea. If that doesn't work please include a
self-contained example showing the problem.
Thanks,
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/sequel-talk/-/UrsVnPcnlVwJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en.