I begin to use driver of mongodb grid-stream.js with node.js to my DB store. Everything was good except when I try display my video stored in mongodb. It shows as if it were a file download. This is the code that I have:
function SendFile(res,id){
var readStream=gfs.createReadStream({
_id:id
}).on('open',function(){
console.log("start..");
}).on('data',function(chunk){
console.log('loading..');
//loading...
}).on("end",function(){
console.log("ready");
//loaded :)
}).on('error', function (err){
res.send(404);//no found :(
console.log(err);
});
readStream.pipe(res);
};
app.get("/:video",function(req,res){
SendFile(res,req.params.video);
});//get file video
//i think the line readStream.pipe(res); is the problem I think that behaves like res.download but a need to behave like: