0

i'm trying to insert file from buffer i've got from multer into sqlite3 using nodejs, multer, and sqlite3.

The code :

let sql2 = `
           INSERT INTO tb_berkas (nama_berkas, hari_input, tgl_input, bulan_input, tahun_input, jam_input, menit_input, ukuran, file)
           VALUES (
              '${this.req.file.originalname}', '${new Date().toLocaleString("id", {weekday:"long"})}', '${new Date().getDate()}',
              '${new Date().toLocaleString("id", {month:"long"})}', '${new Date().getFullYear()}', '${new Date().getHours()}', 
              '${new Date().getMinutes()}', '${this.req.file.size}', '${Buffer.from(this.req.file.buffer, 'binary')}'
           )
           `
           function query2(cb) {
                 koneksi.run(sql2, (err2, result2) => {
                    if(err2) {
                       throw err2;
                    } else {
                       cb(null, result2);
                    }
                 })
           }

The code return error like this :

click

i'm desperate to solve this problem. please, let me know i you guys found the solution.

Geshode
  • 3,600
  • 6
  • 18
  • 32
fey_23
  • 11
  • 1
  • Does this answer your question? [Bind blob parameter in node-sqlite3](https://stackoverflow.com/questions/49111508/bind-blob-parameter-in-node-sqlite3) – Shawn Jun 08 '23 at 06:02

0 Answers0