how to save image file to sequelize db using node.js

1.4k Views Asked by At

First, I send the image file from android to node.js and I want to save the image file to the DB using node.js.

But I don't know how to do that.

This is my Node.js code

.post('/picture', upload.single('files'), (req,res)=>{
    res.json(req.file)
    console.log(req.body)
    console.log(req.file)
})

This is the result from req.file:

fieldname: 'files',
originalname: 'CHOIHYOGIL.png',
encoding: '7bit',
mimetype: 'image/png',
destination: 'images/',
filename: 'c98531598c04abda7e936ef310b147e9',
path: 'images\\c98531598c04abda7e936ef310b147e9',
size: 1372912

I want to save this image to my MySQL DB.

1

There are 1 best solutions below

0
Venkatesh A On

You could save the file locally and store the file directory in the table.