Hi I'm new to nodejs and gridFS I'm trying to display images stored in gridFS to my html page
Currently, I am using this code.
gfs.exist(options, function(err, found){
if(err) return handleError(err);
if(found)
{
console.log("Found Image");
var fs_write_stream = fs.createWriteStream('public/images/'+req.user._id + '_photo' + '.jpg');
var readstream = gfs.createReadStream({
filename: req.user._id + '_photo'
});
readstream.pipe(fs_write_stream);
readstream.on('close', function(){
console.log('file has been written fully');
res.render('profile', {
user : req.user,
message: req.flash('info'),
user_photo_url: 'images/'+req.user._id+'_photo.jpg'
});
});
}
});
But my code need to download image from gridFS. If my server storage is not enough, it should be problematic
Is there any method to display gridFS images to html directly?