D
D
dark_king_132020-02-09 10:35:11
Node.js
dark_king_13, 2020-02-09 10:35:11

How to save base64 to file in nodeJS as image or video?

The server receives the base64 from which to get the image 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 })
        work.remove()
        return res.status(400).json({ message: 'Запись не удалась' })
      })
    }


This code saves the received data, but these pictures then do not open. What to do?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question