Blobs in Firebird can be far larger than 32 kilobytes. Depending on the page size of the database, the maximum size of a single blob can reach slightly less than 4GB (page size 4096) or more than 128GB (page size 16384).
The problem is that - by the sound of it - you have constructed queries by concatenating values into a query string instead of using parameters. Concatenating values into a query string is unsafe (it makes you vulnerable to SQL injection), but in this case you also hit a hard limit. In Firebird, string literals are restricted to 32 kilobytes (or - since Firebird 3 - 64 kilobytes (actually 64kb - 3) when assigned to a blob).
If you want to assign larger values, you have to use a prepared statement with parameters. For example (NOTE: I'm posting Java code, because the error you posted in your question is produced by Jaybird, Firebird's JDBC driver (for Java)):
try (var pstmt = connection.prepareStatement("insert into images (filename, blobdata) values (?, ?)")) {
pstmt.setString(1, "filename.jpg");
pstmt.setBinaryStream(2, someInputStreamForTheData);
// or: pstmt.setBytes(2, fileBytes);
pstmt.executeUpdate();
}
As an aside, saving base64 encoded images in a blob (assuming BLOB SUB_TYPE BINARY
, not BLOB SUB_TYPE TEXT
) does not make much sense to me, images are binary data, and blobs are intended to save binary data. Using base64 introduces unnecessary storage overhead (1 extra byte for every 3 bytes of data).