【问题标题】:How to read multiple files (images) using gridfs-stream如何使用 gridfs-stream 读取多个文件(图像)
【发布时间】:2021-07-14 12:38:08
【问题描述】:
 app.get("/allImages", async (req, res) => {
console.log("All Images Api Called");
gfs.files.find().toArray((err, files) => {
if (!files || files.length == 0) {
  res.status(404).send("No files exits");
}

let arr = [];

files.map((file) => {
  //Read output to browser
  const readstream = gfs.createReadStream(file.filename);
  arr.push(readstream);
});
res.send(arr)
  });

});

我正在尝试发送读取流数组,以便我可以在前端显示多个图像,有人可以帮忙吗

【问题讨论】:

    标签: javascript node.js stream


    【解决方案1】:

    尝试使用readStream.pipe(arr) 而不是arr.push(readStream)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-21
      • 1970-01-01
      • 2021-03-31
      • 2016-04-26
      • 2015-07-18
      • 1970-01-01
      • 1970-01-01
      • 2014-11-08
      相关资源
      最近更新 更多