Blobs are threted like strings, even if it is binary data...
Closed this issue · 2 comments
ramsees commented
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
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
You are right, I was able to extract them using "wb".
Thank you.