【发布时间】:2020-01-06 09:54:03
【问题描述】:
我需要访问multer自定义存储引擎_handleFile函数中的res对象有什么办法吗?目前只有req、file、cb
MyCustomStorage.prototype._handleFile = function _handleFile (req, file, cb) {
this.getDestination(req, file, function (err, path) {
if (err) return cb(err)
var outStream = fs.createWriteStream(path)
file.stream.pipe(outStream)
outStream.on('error', cb)
outStream.on('finish', function () {
cb(null, {
path: path,
size: outStream.bytesWritten
})
})
})
}
没有可访问的 res 对象
【问题讨论】:
-
添加另一个参数并从调用 _handleFile 的位置传递它。我看到该函数根据请求将文件复制到另一个文件。为什么需要响应?