rowland / fb

Firebird Extension Library for Ruby
64 stars 35 forks source link

Blobs are threted like strings, even if it is binary data... #44

Closed ramsees closed 8 years ago

ramsees commented 8 years ago

I have blob field in a table where I store PDFs, there is no problem storing them, but when I retrieve a PDF from then blob field and save it to a file, the PDF file is corrupted, if I do table['pdf_field'].class I get "string", why? it is supposed to be binary.

This is the code to extract the PDF file from the field.

File.open(p_ruta_tmp, "w") do |f|
    f.write(p_adjunto[0]['adjunto_pdf'])
end

If I extract those fileds in C# the fields are extracted fine.

Thanks.

rowland commented 8 years ago

Ruby strings can be binary. If you're on Windows, you may need to open the file with "wb" to keep \r from being translated to \r\n.

Brent

ramsees commented 8 years ago

You are right, I was able to extract them using "wb".

Thank you.