stream to promise
var getGridFsStreams = function (url, fileId) {
return new Promise(function (resolve, reject) {
mongoDBPool.getConnection(url).then(function (db) {
var gfs = Grid(db, mongo);
var readstream = gfs.createReadStream({
_id: fileId
});
streamToPromise(readstream).then(function (buffer) {
var base64 = Buffer(buffer).toString('base64');
return resolve(base64);
}).catch(function (err) {
return reject(err);
});
}).catch(function (err) {
return reject(err);
});
});
}