Updated uploadController.js

Fixed a bug where error messages related to multer would not be displayed properly (it would instead print "undefined").
This commit is contained in:
Bobby Wibowo 2018-07-12 13:34:22 +07:00
parent 616da886f7
commit 917afdf7a8
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF

View File

@ -63,7 +63,7 @@ const upload = multer({
const extname = path.extname(file.originalname).toLowerCase()
if (uploadsController.isExtensionFiltered(extname)) {
// eslint-disable-next-line standard/no-callback-literal
cb(`${extname.substr(1).toUpperCase()} files are not permitted for security reasons.`)
return cb(`${extname.substr(1).toUpperCase()} files are not permitted for security reasons.`)
}
// Re-map Dropzone keys so people can manually use the API without prepending 'dz'
@ -163,7 +163,7 @@ uploadsController.actuallyUpload = async (req, res, user, albumid) => {
}
upload(req, res, async error => {
if (error) { return erred(error.message) }
if (error) { return erred(error) }
if (!req.files || !req.files.length) { return erred('No files.') }