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 #797

Closed
xHyroM opened this issue Dec 11, 2021 · 10 comments · Fixed by #798
Closed

maxFileSize #797

xHyroM opened this issue Dec 11, 2021 · 10 comments · Fixed by #798

Comments

@xHyroM
Copy link

xHyroM commented Dec 11, 2021

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): no

Context

  • Node.js version: 16.13.1
  • Release Line of Formidable (Legacy, Current, Next): next
  • Formidable exact version: 3.1.3
  • Environment (node, browser, native, OS): node
  • Used with (popular names of modules): nextjs

What are you trying to achieve or the steps to reproduce?

    const form = new formidable.IncomingForm({ uploadDir: './uploads', keepExtensions: true, maxFileSize: maxFileSize, allowEmptyFiles: false });

    form.parse(req, (err: any, fields: any, files: any) => {
      if (err) {
        return res.status(413).json({
          name: 'TOO LARGE',
          message: 'Maximum allowed size is 1 GB'
        })
      }

      res.status(200).json({ 
        name: 'OK',
        message: 'File has been uploaded', 
        data: {
          path: files.file.newFilename
        } 
      })
    });

What was the result you got?

It throws an error, but it saves an empty file in the uploads/ folder.

What result did you expect?

It throws an error, the file is not saved

@xHyroM xHyroM added the bug label Dec 11, 2021
@GrosSacASac
Copy link
Contributor

Thanks I will look into it

@xHyroM
Copy link
Author

xHyroM commented Dec 12, 2021

Fixed by #798

@xHyroM xHyroM closed this as completed Dec 12, 2021
@GrosSacASac
Copy link
Contributor

published 3.2.1

@GrosSacASac
Copy link
Contributor

No

@aderchox
Copy link

aderchox commented Oct 7, 2022

Ah this is frustrating, if the latest is v2, then it made sense to be at least in v2 as well...

@aderchox
Copy link

I just used express-fileupload instead.

Thanks, but it's suddenly working for me on v2 as well.

@KnightKrusty
Copy link

KnightKrusty commented Dec 23, 2022

Dammit. I'm not gonna change my entire import system. I guess I'll have to look for another module.

There is dynamic import so you can import inside your function like this

async function uploadfile() {
  const formidable = await import("formidable");
}

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

Successfully merging a pull request may close this issue.

5 participants
@GrosSacASac @aderchox @xHyroM @KnightKrusty and others