I am getting a buffer data from frontend to nodejs as below
<Buffer 53 6f 75 72 63 65 53 63 68 65 6d 61 2c 43 6f 75 6e 74 72 79 4e 61 6d 65 2c 49 44 2c 41 4d 54 5f 45 58 43 4c 5f 54 41 58 2c 41 4d 54 5f 49 4e 43 4c 5f ... 340629006 more bytes>
I am trying to save this data to database using sequelize as below
const DBMODEL = require("../../../models/SaveBufferData")
module.exports = async (req, res) => {
try{
var bufdata = req.file.buffer;
var response = await DBMODEL.SaveBufferData(req.body.fileId, bufdata);
} catch (error) {
console.log('errorerror',error)
res.status(500).json(ResponseManager(false, error.message));
}
I am getting an error as below
node:buffer:669
slice: (buf, start, end) => buf.hexSlice(start, end),
^
Error: Cannot create a string longer than 0x1fffffe8 characters
at Object.slice (node:buffer:669:37)
at Buffer.toString (node:buffer:811:14)
at BLOB._stringify (C:\IWA-BACKEND\PRIMS-local\PRIMS - Iwa\BACKEND\node_modules\sequelize\dist\lib\data-types.js:423:23)
at BLOB.stringify (C:\IWA-BACKEND\PRIMS-local\PRIMS - Iwa\BACKEND\node_modules\sequelize\dist\lib\data-types.js:22:19)
at escape (C:\IWA-BACKEND\PRIMS-local\PRIMS - Iwa\BACKEND\node_modules\sequelize\dist\lib\sql-string.js:40:48)
at C:\IWA-BACKEND\PRIMS-local\PRIMS - Iwa\BACKEND\node_modules\sequelize\dist\lib\sql-string.js:101:14
at String.replace (<anonymous>)
at Object.formatNamedParameters (C:\IWA-BACKEND\PRIMS-local\PRIMS - Iwa\BACKEND\node_modules\sequelize\dist\lib\sql-string.js:96:14)
at Object.formatNamedParameters (C:\IWA-BACKEND\PRIMS-local\PRIMS - Iwa\BACKEND\node_modules\sequelize\dist\lib\utils.js:112:20)
at Sequelize.query (C:\IWA-BACKEND\PRIMS-local\PRIMS - Iwa\BACKEND\node_modules\sequelize\dist\lib\sequelize.js:283:21) {
code: 'ERR_STRING_TOO_LONG'
}
Why am I getting this error? can anyone please explain