We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi, I am not able to handle errors for multiple files .fields([{ name: 'files', maxCount: 10 }]) in multer
.fields([{ name: 'files', maxCount: 10 }])
limits: { fileSize: process.env.MAX_FILE_SIZE }, fileFilter: (req, file, cb) => { if (this.validateExt(file.originalname) ) { req.filesArr.push(file); return cb(null, true); } return cb({ code: 'WRONG_FILE_MIMETYPE' }); }, storage: multerGoogleStorage.storageEngine({ keyFilename: '../gcp-keys.json', filename: (req, file, cb) => { const fileExt = file.originalname.match(/\.[a-z]+$/); const newFileName = `${file.originalname.split('.')[0].slice(0, 15)}_${Date.now()}${ fileExt ? fileExt[0] : '' }`; return cb(null, `upload/${newFileName.replace(/ /g, '_')}`); } }) }); const processUpload = upload.fields([{ name: 'files', maxCount: 10 }]); processUpload(req, res, err => { --------> error is received here if GCS credentials are false,but if GCS credentials are true then error is not received. if (err) { return reject(err); } return resolve(req.files); });
The text was updated successfully, but these errors were encountered:
👍 Upvoting this solution because I had to do this in my fork a well. Otherwise limits.fileSize does not produce an error.
limits.fileSize
Sorry, something went wrong.
No branches or pull requests
Hi,
I am not able to handle errors for multiple files
.fields([{ name: 'files', maxCount: 10 }])
in multerThe text was updated successfully, but these errors were encountered: