Answer the question
In order to leave comments, you need to log in
How to send an image to the frontend in React, which is placed in the new Buffer object?
In express it was done like this:
res
.set('Content-Type', 'image/jpeg')
.send(imageBuffer);
Answer the question
In order to leave comments, you need to log in
If you want to insert an image directly into the html - https://www.npmjs.com/package/datauri#from-a-buffer :
const datauri = new Datauri()
datauri.format('.png', imageBuffer)
console.log(datauri.content) //=> "data:image/png;base64,eGtjZA=="
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question