Hey guys,
I'm using this plugin in combination with Sails.js. I'm using the following code:
video: function (req, res) {
req.validate({
id: 'string'
});
var id = req.param('id');
//This is a normal collection with information to the gridfs document
Videos.findOne(id).exec(function (err, found) {
if (err || !found) return res.notFound();
var options = {_id:found.video, root:'videos'};
gfs.exist(options, function (err, found) {
found ? console.log('File exists') : console.log('File does not exist');
});
var stream = gfs.createReadStream(options);
console.log(stream);
stream.on("readable", function() {
stream.pipe(res);
});
});
}
He finds the file and giving me a "File exists" in my console, but I only get an white blank page as response. Any idea what I'm doing wrong?
//Edit:
Well, I also get a 0 byte file if I'm writing to a file:
var stream = gfs.createReadStream(options);
console.log(stream);
stream.on("readable", function() {
var writer = fs.createWriteStream("test.mp4");
stream.pipe(writer);
});
Hey guys, I'm using this plugin in combination with Sails.js. I'm using the following code:
He finds the file and giving me a "File exists" in my console, but I only get an white blank page as response. Any idea what I'm doing wrong?
//Edit: Well, I also get a 0 byte file if I'm writing to a file: