multer
multer copied to clipboard
Potential Issue with destination Parameter Type in Multer Custom Storage
in this file https://github.com/expressjs/multer/blob/master/StorageEngine.md its giving a template for making a custom storage engine but there is a problem I guess..
function MyCustomStorage (opts) {
this.getDestination = (opts.destination || getDestination)
}
function MyCustomStorage (opts) {
this.getDestination = (opts.destination || getDestination)
}
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
})
})
})
}
its calling this.getDestination as function but it may not be a function if user provided "destination property" in the constructor.. or I am getting this wrong?
Edited by Ulises to highlight syntax