multiple files upload
- Dominant language
- JavaScript
- Stars
- 12.1k
- Forks
- 1.1k
- Avg merge
- 8d 2h
- Merged PRs (30d)
- 21
Description
In **fileFileter** tried to handle custom errors on file extensions, on fileName length - and got in error from multer.
If I have an error I do so
``` javascript
if (!new RegExp(config.allowedFileExt + "$").test(file.originalname)) {
err = new Error(file.originalname + ": File should have *.xlsx extension");
return cb(err);
} else if (file.originalname.length > config.maxFileNameLength) {
err = new Error(file.originalname + ": Filename shouldn't exceed 64 characters");
return cb(err);
} else {
cb(null, true);
}
```
The main thing is if the first file is valid and after that we have two errors I end up with the error from the code disk.js:
``` javascript
DiskStorage.prototype._removeFile = function _removeFile (req, file, cb) {
var path = file.path
delete file.destination
delete file.filename
delete file.path
fs.unlink(path, cb)
}
```
which try to remove twice(the count of errors) that one valid first saved file. In first case it do it right, but in second it cannot find the **file.path** (it was removed in previous call) and throw error.
Contributor guide
Assessment
This issue has not been assessed yet.