我正在使用gridform在gridfs中保存文件,如何让文件将其返回给用户?
答案 0 :(得分:0)
可能的解决方案,看documentation here
gridfsstream = require('gridform/node_modules/gridfs-stream') mongoose = require('mongoose') var conn = mongoose.createConnection(..); conn.once('open', function () { // oid: string representing object id, identifier of a gridfs file // res: express response object gridfsstream(conn.db, mongoose.mongo).createReadStream(oid).pipe(res); })