How to "rebuild" a file from the buffer stored in the database?

Asked

Viewed 18 times

0

I’m in great doubt.

I upload files and receive them on a Node server with the help of middleware multer, the data comes something like this:

inserir a descrição da imagem aqui

Then I take this file and save in the database the result of JSON.stringfy() from it...

When I do the query in the database what is returned me the information stored as originalName and etc, already in the buffer is returned this array:

inserir a descrição da imagem aqui

then I would like to know how to "rebuild" the file from this data, both in Node itself and using javascript in the browser itself.

From now on, I thank you for your help.

1 answer

0

Fs module lets you save files from a Buffer.

fs.writeFile(filename, Buffer.from(data));

Browser other questions tagged

You are not signed in. Login or sign up in order to post.