# Blob to file

**URL:** <https://www.ruby-forum.com/t/blob-to-file/133182>\
**Category:** Ruby\
**Created:** [March 28, 2008, 4:13pm UTC](https://www.ruby-forum.com/t/blob-to-file/133182 "2008-03-28T16:13:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimache](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c67d28/32.png) [@jimache](https://www.ruby-forum.com/u/jimache)\
**Post date:** [March 28, 2008, 4:13pm UTC](https://www.ruby-forum.com/t/blob-to-file/133182/1 "2008-03-28T16:13:21Z")

</div>

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.
