I’m using Flex 4 Air (sdk 4.5) and SQLite to store blobs (png files) using this code:
sql = "INSERT INTO pages (id, data) VALUES (:id, :data)";
sqlStatement.text = sql;
sqlStatement.parameters[":id"] = file.name;
sqlStatement.parameters[":data"] = file.data;
sqlStatement.execute();
The table is defined like this:
CREATE TABLE "pages" ("id" varchar, "data" blob)
The problem is that the data stored has 3-5 extra bytes added to it, in the beginning of the data chunk. (If I store a 1000 bytes png, the data stored in the blob typically become 1004 bytes – confirmed by examining the SQLite file outside the Flex environment).
When reading the data back, using…
sql = "SELECT id, CAST(data AS ByteArray) AS data FROM pages"
…I have to trim the data ByteArray 3-5 bytes to get a valid image.
Clue?
Check this out:
What is the first bytes in a Blob column SQlite Adobe AIR? Blob Sizeinfo?
And if you’re having trouble displaying them:
Flex local SQLite BLOB display