question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

File size limit cancels file upload only after all bytes are received

See original GitHub issue

I’ve been using multer for file uploads, and I’ve noticed an issue with the file size limit. I’m using the limits option to prevent the upload of files that are too large.

  const upload = multer({
    storage: multer.memoryStorage(),
    limits: {
      fieldNameSize: 255,
      fileSize: 500000,
      files: 1,
      fields: 1
    }
  });

When uploading an image to my API, multer seems to wait until it has received all of the image bytes before failing with the “LIMIT_FILE_SIZE” code.

Isn’t it a security vulnerability if your API allows someone to upload an arbitrarily large file before failing the request? Is there another technique for preventing the behavior?

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:45
  • Comments:31 (8 by maintainers)

github_iconTop GitHub Comments

10reactions
linus-hologramcommented, Apr 13, 2020

Is there any update in regards to this issue? Does this really persist since 2016?

8reactions
DiegoRBaquerocommented, Jan 19, 2017
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to limit the file size when uploading with multer?
This all works fine and the file gets uploaded. The only thing that is not working is the limit on the max size....
Read more >
File Upload example has limit of 2048 bytes — oracle-tech
I am following an example on how to perform a file upload from a JSF page in Frank ... InputStream.read(buffer) stops reading at...
Read more >
File Size Limit Exceeded Error Under Linux and Solution
I am getting an error “file size limit exceeded” under Linux. ... size (kbytes, -m) unlimited open files (-n) 1024 pipe size (512...
Read more >
Attach large files to Outlook messages or events
If the file size is between 3 MB and 150 MB, create an upload session, and iteratively use PUT to upload ranges of...
Read more >
How to Increase the Max Upload Size in WordPress - Kinsta
A low WordPress upload size limit stops you from uploading large files, plugins, and themes. If you're building a media-heavy website, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found