Page 1 of 1

CLOB to BLOB (RESOLVED)

Posted: Wed Mar 11, 2020 8:11 am
by lawingo
I have images stored as CLOB data in a database file. Currently to display this CLOB data on the web I have a routine that disassembles the string and reassembles it using 65k chunks. I then set the image on the screen:

Code: Select all

#ExitPhoto.CurrentItem.Image <= #SYS_APPLN.CreateBitmap( #Base64 )
Everything works like a charm.

Now - I would like to start converting this CLOB data into a BLOB datatype field. BLOBs are so much easier to use with third party reporting software (and just in general).
I looked through the forum and found a nifty utility #SYS_WEB.CreateBlob. My thinking was as I am breaking this CLOB data out and reassembling it into a base64 string I could save the Base64 string as a Blob using this new utility. It doesn't work and was hoping someone could help me find out why.

Code:

Code: Select all

#W_BLOB := #SYS_WEB.CreateBlob( #Base64 "image/png" )
Failure is on that line of code.
Error: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.

I know the base64 string is valid because the images are created on the screen (if I leave this new code out). I'm not sure what " 'atob' on 'Window' " is.

I'm thankful for your help.

-Chad-
Sherrill Furniture Company

Re: CLOB to BLOB

Posted: Thu Mar 12, 2020 1:17 am
by lawingo
So I got it working. I had to remove the header info(data:image/png;base64,) from the CLOB String to get the encoding correct.

Just in case someone else out there has set up your DB to capture images with CLOBs and you would like to convert to BLOB here is your code:

Code: Select all

#listcount := #base64.CurChars
#base64 := #base64.Substring( 23 #listcount )
#W_BLOB := #SYS_WEB.CreateBlob( #Base64 'image/png' )
Best,
Chad