0
gfs.files.find({}).toArray(function(err, file) {
if (!err) {
console.log('file length ', file.length);
if (file.length > 0) {
file.forEach(function(each) {
process.setMaxListeners(0);
var mime = 'image/jpeg';
res.set('Content-Type', mime);
read_stream = gfs.createReadStream({ "filename": each.filename });
read_stream.pipe(res, { end: false });
done++;
});
read_stream.on('end', function() {
process.setMaxListeners(0);
if (done === file.length) {
res.send();
}
});
} else {
res.json('File Not Found');
}
}
});
这是不正常工作。只有一个文件显示在浏览器中。我现在做什么?它将没有任何zip文件。多个文件附加在节点j的响应对象中
请说明您的代码的目标是什么,您尝试了什么,以及您可能会认为是什么问题。 – DrakaSAN
我在数据库中有巨大的图像/音频/视频文件。我想将单个api响应中的所有文件发送到前端。 –