So I am using mongoDB as my database and I have saved an image in mongoDB in binary format.
The image below is how the data is being displayed in my database.
I have tried the following:
<img src="data:image/jpeg;base64{<%= user.img.data %>}"/>
But the above code does not seem to work. Please note I am using EJS as a tempting engine.
After doing the inspect element on google chrome I found that the data was being shown like so:
I am not sure how to read this binary image and display it in a img tag in html.
UPDATE:
After making the changes recommended by Alex Matos in the comments I get the following output:



var buf2 = new Buffer(user.img.data).toString('base64'); console.log(buf2.toString());I suppose that you uses nodejs