I have a simple code that downloads .zip archive from server, extracting it into temp files and after saves the data on database in base64 format. The problem is that when I read this data from DB, where the type is "BLOB", I get incorrect simbols which are not in base64 format.
Code to save the data
Code: Select all
-- Extract the file from zip archive
revZipExtractItemToFile pArchive, tItem, tFileLocation
-- Get the file data
put URL("binfile:" & tFileLocation) into tFileBin
if tFileBin is not empty then
-- Encode the file to base64
put base64Encode(tFileBin) into tFileBase64
-- Insert the file to DB
put "INSERT INTO images values('" & tItem & "','" & tFileBase64 & "')" into tSQL
revExecuteSQL gMediaDbID, tSQL
code to read the data
Code: Select all
put revQueryDatabase(gMediaDBID,"select imagedata from images where imageid ='"& pID &"'") into tCursor
--Read the image from the database
put revDatabaseColumnNamed(tCursor, "imagedata", "tImage") into tErrorMsg
revCloseCursor tCursor --Close Cursor
put base64Decode(tImage) into tImage
Thanks in advance.