I am using gridfs-stream https://github.com/aheckmann/gridfs-stream & currently i am on displaying image from gridFS.
When reading data it gives me following output. When i append this data to <img src="data:image/jpeg;base64,(data)">
, the image doesn't show.
gfs
// create a read stream from gfs...
.createReadStream({ filename: 'error1.png' })
// and pipe it to Express' response
.pipe(res);
Output res :-
Edited :-
I tried this :-
img.src = 'data:image/jpeg;base64,' + btoa(res);
Output rendered is :-
<img src="data:image/jpeg;base64,W29iamVjdCBPYmplY3Rd">
No image shown.