Currently, I am encoding images in a Vue.js
application to base64 and save them in a MySQL
database using feathers.js
and feathers-objection
. The data type in the table is LONGTEXT
, which works fine for small images.
Sometimes, if the image is larger (>1MB) I get a Data too long for column
error from the database driver mysql2
.
In the feathers
documentation they are saving images to a blob storage, like google drive, which unfortunately is no option for this use case.
The table definition is done via knex.js
:
exports.up = function (knex) {
return knex.schema
.createTable("attachments", (table) => {
table.increments("id");
table.integer("ticketId");
table.text("uri", "LONGTEXT");
table.integer("size");
table.string("type");
table.string("name");
table.timestamp("createdAt").nullable();
table.timestamp("updatedAt").nullable();
})
.then(() => console.log("Created attachments table")) // eslint-disable-line no-console
.catch((e) => console.error("Error creating attachments table", e)); // eslint-disable-line no-console
};
Are there some other options, e.g. datatypes to save longer base64 encoded URIs?