Skip to content
New issue

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

maxFileSize option is not working... #914

Closed
KnightKrusty opened this issue Dec 23, 2022 · 1 comment
Closed

maxFileSize option is not working... #914

KnightKrusty opened this issue Dec 23, 2022 · 1 comment
Labels

Comments

@KnightKrusty
Copy link

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: [email protected]
  • 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...

@KnightKrusty
Copy link
Author

Seems to be already solved in latest version: 3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant