我将 GridFsStorage 与 multer 一起使用。这是我输出 TypeError 的代码。
const mongoURI=DB
const conn = mongoose.createConnection(mongoURI);
let gfs;
conn.once('open', function() {
//STREAM INITIALIZING
gfs=GridFSBucket(conn.db, mongoose.mongo)
gfs.collection('uploads')
})
gfs.files.findOne({filename:req.params.filename},(err,file)=>{
const readstream = gfs.createReadStream(file.filename)
readstream.pipe(res)
})