I would like to
// store binary image file in SQLite, then
// select binary image file from SQLite db, and
// put the binary data into an image object
there seems to be two methods that I can discern from reading forum posts
// method 1: keep everything in binary and don't use base64encode - base64decode
// method 2: use base64encode and base64decode before and after database manipulation
I have experimented extensively and have read relevant posts
http://forums.runrev.com/viewtopic.php? ... ary#p40458
http://forums.runrev.com/phpBB2/viewtop ... =49&t=8320
I can store and retrieve text and numbers from a database and display them in various way but this is the first time I have to work with images and audio.
1) I seem to be able to store 'something' in the database but I'm not sure what it is
2) when I go to retrieve it I retrieve this 'something' but it won't display
Here is some code that I have been fighting with
Code: Select all
//attempt #1
connectToDb --wrapper handler for connecting and passing global dbID and error handling
answer file ""
put URL ("binfile:" & it) into tImageData
set the text of image "testImage" to tImageData --this displays correctly
//update binary image file to db
put "1" into tIndex
put "UPDATE categories SET catImage = :1 WHERE catID_pk = :2" into tQuery
revExecuteSQL gDatabaseID, tQuery, "*btImageData", "tIndex" --'something' (binary data??) saved to blob type in db
//try to extract text data from db
put "1" into tIndex
put "SELECT :1 FROM categories WHERE catID_pk = :2" into tQuery
put revQueryDatabase(gDatabaseID, tQuery, "*bcatImage", "tIndex") into tCursorID
put revDatabaseColumnNamed(tCursorID, "catImage") into tImageDataExtracted
set the text of image "extracted" to tImageDataExtracted --!!nothing displays
revCloseCursor tCursorID
closeDb gDatabaseID --close db handler
Note: I also tried all the combinations of including or not including *b. there are two locations above where *b is used but none of the 4 combinations work
The other variation is
Code: Select all
//before saving to db
put base64Encode(tImageData) into tDataEncoded
//after extracting from db
put base64Decode (tImageDataExtracted) into tImageDataExtracted
NOTE: I also tried using both 'text' type and 'blob' types for the base64encoded data
If I can get that method to work, does anyone have any idea which db type (text or blob etc) I should use to store the encoded data?
Anyone have any ideas? I am completely exhausted.
Coffee