NodeJS how to save the base64 to a file like a picture or a video?

The server receives the base64 to get a picture or video and save it.
Current code:
for (let i = 0; i < length; i++) {
 let buff = new Buffer(content[i], 'base64')
 fs.writeFileSync(`${pathArr[i]}`, buff, function(err) {
 consola.error({ message: err.message, badge: true })
 return res.status(400).json({ message: 'Recording failed' })

This code saves the data, but these pictures then do not open. What to do?
April 7th 20 at 10:46
0 answer

Find more questions by tags Node.js