I have an image (png) file stored in my MongoDB as binary data. My MongoDB schema looks like below :
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
ImageSchema = new Schema (
{ title : String,
picture: { content: Buffer, contentType: String }
}
);
The mustache code looks like below:
var template = " <h1></h1>";
var rendered = Mustache.render(template, imageObject);
$('#target').html(rendered);
The data in MongoDB looks like below, it has been shortened as it is too long:
"picture" : {
"contentType" : "image/png",
"content" : BinData(0,"iVBORw0KGgoAAAANSUhEUg ...")
}
What is the way to convert this binary data to image and especially fit it into the Mustache template for display ?
Thanks.
via A.G.Progm.Enthusiast
No comments:
Post a Comment