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.

What do you think about extending Multer with a few new options?

See original GitHub issue

What do you think about extending Multer with a few new options such as minCount and count as an addition to existing maxCount?

Honestly speaking, I need these options. For now, I can check only maxCount. If my application needs to get at least three pictures from a client, I cannot check this with Multer. For now, Joi handles it. I don’t like to separate these validations mechanism. Validating at least the basic things with Multer would be great.

Also, we can add fileType option. We can use this library to check the files’ types. I understand that this is possible to do with the Multer’s fileFilter function. But I think it would be great to have this filter. It will help the new users to enter into Multer faster. They will have a few useful options out of the box.

@LinusU, I will be happy to hear your thoughts.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ryhincheycommented, Apr 14, 2020

The reason that we only provide maxCount is since the use case here is only to be able to terminate early as to prevent DOS attacks, it’s not intended as a form validation library.

I’m going to go ahead and close this issue per @LinusU comment. Implementing further checks around the number of files being uploaded is currently out of scope for multer.

0reactions
shierrocommented, May 2, 2019

Hi, i also think that the minCount option would be very useful. i have a case, where I upload multiple files via .fields([...array])

I wanted to check if those files exist, before sending it to s3 via multer-s3

Was looking for something like { name: 'avatar', maxCount: 1, minCount: 1 } or { name: 'avatar', maxCount: 1, required: true }

and landed on this issue 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Express multer middleware
Multer is a node.js middleware for handling multipart/form-data , which is primarily used for uploading files. It is written on top of busboy...
Read more >
How to store a file with file extension with multer?
This answer just points that Multer does not append a file extension, but the OP asks for a way to append the extension....
Read more >
Multer: Easily upload files with Node.js and Express
With Multer, you can handle single or multiple files in addition to text inputs sent through a form. Remember that you should only...
Read more >
Uploading Files Using Multer in a Node.js Application
In this article, we will see how to use Multer to handle multipart/form-data using Node.js, Express and MongoDB.
Read more >
File upload with multer in node.js and express - Medium
Multer supports uploading single as well as multiple uploads. upload.single is used for uploading a single file. As I have mentioned before ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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