Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential Issue with destination Parameter Type in Multer Custom Storage #1278

Open
anoniz opened this issue Oct 12, 2024 · 0 comments
Open

Comments

@anoniz
Copy link

anoniz commented Oct 12, 2024

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

@anoniz anoniz added the bug label Oct 12, 2024
@UlisesGascon UlisesGascon changed the title "Potential Issue with destination Parameter Type in Multer Custom Storage" Potential Issue with destination Parameter Type in Multer Custom Storage Oct 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants