Gathering detailed insights and metrics for express-fileupload-validator
Gathering detailed insights and metrics for express-fileupload-validator
npm install express-fileupload-validator
Typescript
Module System
Node Version
NPM Version
TypeScript (99.67%)
JavaScript (0.33%)
Total Downloads
1,716
Last Day
1
Last Week
10
Last Month
43
Last Year
240
2 Stars
23 Commits
2 Watching
2 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
2.0.1
Package Id
express-fileupload-validator@2.0.1
Unpacked Size
75.65 kB
Size
21.37 kB
File Count
104
NPM Version
7.16.0
Node Version
14.16.1
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
-23.1%
10
Compared to previous week
Last month
4.9%
43
Compared to previous month
Last year
-40%
240
Compared to previous year
Validator for express-fileupload package.
1npm i express-fileupload
In order to use this package you need to use express alongside express-fileupload.
1const express = require('express'); 2const expressFileupload = require('express-fileupload'); 3 4const app = express(); 5// ... 6app.use(expressFileupload()); 7 8app.listen(8080);
1const express = require('express'); 2const { ExpressFileuploadValidator } = require('express-fileupload-validator'); 3 4// You can export it to reuse the same validations. 5const expressFileuploadValidator = new ExpressFileuploadValidator({ 6 minCount: 2, 7 maxCount: 8, 8 allowedExtensions: ['jpg', 'png', 'gif'], 9 allowedMimetypes: ['image/jpg', 'image/jpeg', 'image/png', 'image/gif'], 10 maxSize: '20MB', 11}); 12 13const router = Router(); 14 15router.post('/upload-images', (req, res) => { 16 if (!req.files || !req.files.images) { 17 // We didn't get any files at all here.. 18 } 19 20 try { 21 expressFileuploadValidator.validate(req.files.images); // Validate the file or files. 22 // Everything ok we can save the files safely now :) 23 } catch (e) { 24 console.log(e.errors); // Validation error messages... 25 } 26});
Type: object
In addition, you can specify the below options.
Type: number
Default: -1
(no limit)
The number of minimum files.
Type: number
Default: -1
(no limit)
The number of maximum files.
Type: string | number
Default: -1
(no limit)
The minimum size per file.
Can be formatted size, for example: 2MB
, 5GB
and etc.
Can be size in bytes, for example: 6291456
which is 6MB.
Type: string | number
Default: -1
(no limit)
The maximum size per file.
Can be formatted size, for example: 2MB
, 5GB
and etc.
Can be size in bytes, for example: 6291456
which is 6MB.
Type: string[]
Default: []
List of allowed file extensions, for example: ['jpg', 'png']
.
Type: string[]
Default: []
List of disallowed file extensions, for example: ['jpg', 'png']
.
Type: string[]
Default: []
List of allowed file mimetypes, for example: ['image/jpg', 'image/png']
.
Type: string[]
Default: []
List of disallowed file mimetypes, for example: ['image/jpg', 'image/png']
.
Type: bool
Default: true
Will decide if to abort as soon as possible, that means you will always gets the first error.
If abortEarly is false
you will get all collected files errors.
You can specify object with your custom error messages. Please notice you need to keep the placeholders {} to keep the error messages clean.
1const expressFileuploadValidator = new ExpressFileuploadValidator({}, {
2 minCount: 'Too few files, minimum {0} are expected but {1} are given',
3 maxCount: 'Too many files, maximum {0} are allowed but {1} are given',
4 minSize: 'Minimum expected size for file {0} is {1} but {2} detected',
5 maxSize: 'Maximum allowed size for file {0} is {1} but {2} detected',
6 allowedExtensions:
7 'File {0} has an incorrect extension of {1}, allowed extensions are: {2}',
8 disallowedExtensions:
9 'File {0} has an incorrect extension of {1}, disallowed extensions are: {2}',
10 allowedMimetypes:
11 'File {0} has an incorrect mimetype of {1}, allowed mimetypes are: {2}',
12 disallowedMimetypes:
13 'File {0} has an incorrect mimetype of {1}, disallowed mimetypes are: {2}',
14});
Throws ExpressFileuploadValidatorErrors
if there are errors.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/23 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
13 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More