blob to file

J

jhn Vln

Hi everyone,

I have a bunch of pdf files stored in a database (blob field) and now i
am asked to "transform" them into file system.
Is there any way to do that;
I tried something along the lines of
FileObject.find:)all).each do |fo|
f = File.new("#{fo.name}" + ".pdf", "w")
f << fo.file_field
f.close
f = nil
end

The files get created but when i try to open the newly pdf file created
they are blank (just blank pages in each doc)

Any ideas on this; any input is appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top