I'm uploading an image in GridFS but have no idea how to display this in an <img >
tag.
I tried the following code:
conn.once('open', function () {
var gfs = Grid(conn.db, mongoose.mongo);
gfs.files.find({ filename: 'img1.png' }).toArray(function (err, files) {
if (err) { console.log(err); }
console.log(files);
});
});
I get the result:
[ { _id: 5316f8b3840ccc8c2600003c,
filename: 'img1.png',
contentType: 'binary/octet-stream',
length: 153017,
chunkSize: 262144,
uploadDate: Wed Mar 05 2014 15:43:07 GMT+0530 (India Standard Time),
aliases: null,
metadata: null,
md5: '915c5e41a6d0a410128b3c047470e9e3' } ]
Now this is just the file info not the actual file data.
How to display image in HTML?