Hi,
Can someone help with uploading image and retrieving it from SQLite?
Table structure:
CREATE TABLE Images (
ID INTEGER PRIMARY KEY AUTOINCREMENT,
Image BLOB NOT NULL
);
Insert:
self.view.custom.UploadedFile = event.file.getBytes()
Uploaded image in db like:
<ArrayWrapper>: [-119, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, -57, 0, 0, 0, 81, 8, 6, 0, 0, 0, 102, 58, -78, -104, 0, 0, 0, 1, 115, 82, 71, 66, 0, -82, -50, 28, -23, 0, 0, 0, 4, 103, 65, 77, 65, 0, 0, -79, -113, 11, -4, 97, 5,....
Retrieved image code:
import base64
query = 'SELECT Image FROM Images where ID= ?'
results = system.db.runPrepQuery(query, [currentValue.value])
if results and len(results) > 0:
imageBlob = results[0][0]
base64Data = base64.b64encode(bytes(imageBlob)).decode('utf-8')
self.getChild("root").getChild("Image").props.source = "data:image/jpeg;base64," + base64Data
Image:
data:image/jpeg;base64,PEFycmF5V3JhcHBlcj46IFstMTE5LCA4MCwgNz...