Hello,
I'm having a problem saving files to blob fields when using an SQLite3 database.
For some reason it only saves somewhere between 4kb and 8kb of data.
I'm trying this using the built in server (php spark serve which calls php's built in server) and I'm using Codeigniter 4.5.5 on php 8.3
In the migration I declared the blob field like this:
I have created an entity called "File" using spark (no changes made to it).
I created a model called "FilesModel" using spark and the only changes I made are:
- set the return type to the entity mentioned above:
- set the allowed fields
I'm saving the data after upload like this:
Saving data to a MySQL or MariaDB database works without any issues. Just SQLite3 seems to have a problem.
I know saving files in blob fields is not recomended, I know I could save the files as base64 encoded strings or to some block storage, but I don't have any choice in this mater.
Are there any additional configuration options that need to be set for SQLite3?
I'm having a problem saving files to blob fields when using an SQLite3 database.
For some reason it only saves somewhere between 4kb and 8kb of data.
I'm trying this using the built in server (php spark serve which calls php's built in server) and I'm using Codeigniter 4.5.5 on php 8.3
In the migration I declared the blob field like this:
PHP Code:
'content' => [
'type' => 'BLOB',
'null' => true,
],
I have created an entity called "File" using spark (no changes made to it).
I created a model called "FilesModel" using spark and the only changes I made are:
- set the return type to the entity mentioned above:
PHP Code:
protected $returnType = File::class;
PHP Code:
$allowedFields = ["filename", "content", "mimetype", "size"];
I'm saving the data after upload like this:
PHP Code:
$data = [
... other fields...
'content' => file_get_contents(...temp file path...)
];
$savedFile = new \App\Entities\File();
$savedFile->fill($data);
$model = new FilesModel();
$model->save($savedFile);
Saving data to a MySQL or MariaDB database works without any issues. Just SQLite3 seems to have a problem.
I know saving files in blob fields is not recomended, I know I could save the files as base64 encoded strings or to some block storage, but I don't have any choice in this mater.
Are there any additional configuration options that need to be set for SQLite3?
how | | toolbar |