Home » SQL & PL/SQL » SQL & PL/SQL » Base64 String to Image (Oracle 10g)
Base64 String to Image [message #388611] Wed, 25 February 2009 12:12 Go to next message
2jhenry01
Messages: 4
Registered: February 2009
Junior Member
Hello-

I need to pull BLOBs (stored as Base64 strings) from our database and store as bitmap images externally.

Can anyone offer some direction here? I'm not sure how to do this using only PL/SQL.

I did try to convert the BLOB using UTL_ENCODE.base64_decode and then using UTL_FILE.put_raw to write the new file out. The file is written but is unreadable.

Please help?

TIA!
Re: Base64 String to Image [message #388615 is a reply to message #388611] Wed, 25 February 2009 12:19 Go to previous messageGo to next message
Michel Cadot
Messages: 68647
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
BLOB is binary and so not handle by Oracle.
Only YOU know what is its format and how to read it.

Regards
Michel
Re: Base64 String to Image [message #388621 is a reply to message #388615] Wed, 25 February 2009 12:56 Go to previous messageGo to next message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
http://fdegrelle.over-blog.com/article-12589417.html
Re: Base64 String to Image [message #388633 is a reply to message #388611] Wed, 25 February 2009 13:49 Go to previous messageGo to next message
2jhenry01
Messages: 4
Registered: February 2009
Junior Member
Thank you both for your responses.

I'm able to write the external file just fine. But it's not readable as a bitmap. I guess I'm confused as to what I need to convert it to?? As I said, it's being stored in the BLOB column as a Base 64 String. I thought by decoding that into a RAW type that I could write it out to a file with a .BMP extension and it would be fine. That hasn't worked though.

Can you provide further direction?
Re: Base64 String to Image [message #388637 is a reply to message #388611] Wed, 25 February 2009 14:21 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>The file is written but is unreadable.
What software utility is being used to open & read the resultant file?
Re: Base64 String to Image [message #388638 is a reply to message #388611] Wed, 25 February 2009 14:25 Go to previous messageGo to next message
2jhenry01
Messages: 4
Registered: February 2009
Junior Member
I'm just trying to open the file (.bmp) using Paint in Windows.
Re: Base64 String to Image [message #388641 is a reply to message #388611] Wed, 25 February 2009 14:40 Go to previous messageGo to next message
2jhenry01
Messages: 4
Registered: February 2009
Junior Member
If the data I'm trying to convert was encoded to base64 by an outside application (C++ code) and inserted into the database ... will the UTL_ENCODE.base64_decode be able to convert this to it's original binary format?
Re: Base64 String to Image [message #388691 is a reply to message #388641] Wed, 25 February 2009 23:10 Go to previous messageGo to next message
Michel Cadot
Messages: 68647
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Maybe the original C++ is not correct in its encoding.

Regards
Michel
Re: Base64 String to Image [message #388740 is a reply to message #388641] Thu, 26 February 2009 00:58 Go to previous message
Frank
Messages: 7901
Registered: March 2000
Senior Member
Why store strings in Blobs instead of Clobs?
Are you sure the contents are base64-encoded and not binary?
Previous Topic: SMTP Mail Attachment
Next Topic: WIn XP, Oracle 10g
Goto Forum:
  


Current Time: Fri Apr 26 13:08:37 CDT 2024