Open ghost opened 8 years ago
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
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:
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.
@ViktorSoroka is this still an issue ?
Have not tested it since then.
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
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:
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.