I want to show the store image as blob in HTML using handles bars
This is how I query the image in app.js
app.get('/',(request,response)=>{
db.query('select Image from pictures LIMIT 3', function(err, result) {
let base64String = result.toString("base64");
//var image = '<img src="'+base64String+'" class="denr-logo">';
response.render('NPPNP',{images:base64String});
//response.send(base64String);
});
Several sites they converted to base64 string and combined it with tag and 'data:image;base64,xxx=='
Actually I research several method, examples but I can't understand on how they do.
When I console.log the base64String, it showing [object Object] and when I pass it to the HTML nothing...
Using handlebars
{{#each images}}
{{this.Image}}
{{/each}}
This is the result before converting to base64.
[{"Image":{"type":"Buffer","data":[137,80,78,71,13,10,26,10,0,0,0,13............
First you'll need to get the binaries values using `result[0].Image' as we can see in your result
Second convert binaries to base64 this will give you like this iVBORw0KGgoAAAANSUhEU==
var base = Buffer.from(result[0].Image);
var conversion = base.toString('base64');
var send = '<img src="data:image/png;base64,'+conversion+'" alt="something familiar"/>';
response.send(send);
It might fixed your problem, I did it on my own and it worked