is there anyway to use limits object to abort only the file that violate limits, not the whole array in multer.array('field',n) ?
- Dominant language
- JavaScript
- Stars
- 12.1k
- Forks
- 1.1k
- Avg merge
- 8d 2h
- Merged PRs (30d)
- 21
Description
for example
```
var multerS=multer({storage:storageSetting,limits:{fileSize:XXXXX})
app.post("/",function(req,res,next) {
multerS.array('field',10)(req,res,function(err){
if(err) {console.log(err); next();}
else{next();}
})
}
, NEXT_MIDDLEWARE, NEXT_MIDDLEWARE2,...);
```
In my example code, I try to call the next middleware by calling next() even if there is an error from multerS limits ( in this case it's fileSize ). The result is that
1) if none of the file in "field" exceed file limit, then everything works correctly: All files are written to disk, in all subsequent middlewares req object is appended with files attribute that **contains every files** from "field" and middlewares work fine.
2) if >=1 files does exceed limit, then FILE_SIZE_LIMIt error is emitted and all files are rejected, not written to disk but req object in subsequent middlewares has files attribute that contains only **files that do not violate the limits,** and middlewares work just fine.
What I want is that only the files which violate limit are reject, but the rest are still accepted. Is there anyway to do this other than accepting all files at first then individually remove the files from disk later?
Contributor guide
Assessment
This issue has not been assessed yet.