maxFileSize option is not working...
KnightKrusty opened this issue · comments
Support plan
- Which support plan is this issue covered by? (Community, Sponsor, Enterprise): Community
- Currently blocking your project/work? (yes/no): yes
- Affecting a production system? (yes/no): yes
Context
- Node.js version: v16.18.1
- Release Line of Formidable (Legacy, Current, Next):
- Formidable exact version: formidable@3.1.3
- Environment (node, browser, native, OS): node
- Used with (popular names of modules): node:fs
What are you trying to achieve or the steps to reproduce?
its taking care of all things perfectly fine the problem is that i have used below options, where maxFileSize is around 50 - 52mb but when i upload the file bigger than that, the temp file is created and throws an error but file and fields are completely empty so i dont have access to temp file path so i can not remove the temp uploaded file... or the formidable should have deleted the temp created file itself
multiples: false,
maxFileSize: 50 * 1024 * 1024,
allowEmptyFiles: false,
keepExtensions: true,
uploadDir: root_upload_path,
filter: function ({ name, originalFilename, mimetype }) {
const FILE_TYPES = [
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"application/vnd.ms-excel",
"application/zip",
"text/csv",
];
return mimetype && FILE_TYPES.includes(mimetype);
},
form.parse(req, async (err, fields, file) => {
if (err) {
if (err.code === formidable.errors.biggerThanMaxFileSize) {
console.log(file) // {}
console.log(fields) // {}
reject("File is way too big, Please upload file under 50mb");
return;
}
}
What was the result you got?
Bigger files are uploaded inside folder with random string eg c798501cb43645d2a87a5b300.csv
What result did you expect?
file object should have a filepath propety indicating the temp path so the upload file can be removed or it should have removed the tmp file itself...
Seems to be already solved in latest version: 3.2