@@ -104,2 +104,4 @@ var is = require('type-is') | ||
| busboy.on('file', function (fieldname, fileStream, { filename, encoding, mimeType }) { | ||
| if (fieldname == null) return abortWithCode('MISSING_FIELD_NAME') | ||
| // don't attach to the files object, if there is no file | ||
@@ -106,0 +108,0 @@ if (!filename) return fileStream.resume() |
+11
-10
| { | ||
| "name": "multer", | ||
| "description": "Middleware for handling `multipart/form-data`.", | ||
| "version": "2.0.0", | ||
| "version": "2.0.1", | ||
| "contributors": [ | ||
@@ -23,15 +23,16 @@ "Hage Yaapa <captain@hacksparrow.com> (http://www.hacksparrow.com)", | ||
| "append-field": "^1.0.0", | ||
| "busboy": "^1.0.0", | ||
| "concat-stream": "^1.5.2", | ||
| "mkdirp": "^0.5.4", | ||
| "busboy": "^1.6.0", | ||
| "concat-stream": "^2.0.0", | ||
| "mkdirp": "^0.5.6", | ||
| "object-assign": "^4.1.1", | ||
| "type-is": "^1.6.4", | ||
| "xtend": "^4.0.0" | ||
| "type-is": "^1.6.18", | ||
| "xtend": "^4.0.2" | ||
| }, | ||
| "devDependencies": { | ||
| "deep-equal": "^2.0.3", | ||
| "express": "^4.13.1", | ||
| "form-data": "^1.0.0-rc1", | ||
| "fs-temp": "^1.1.2", | ||
| "mocha": "^11.3.0", | ||
| "express": "^4.21.2", | ||
| "form-data": "^4.0.2", | ||
| "fs-temp": "^1.2.1", | ||
| "mocha": "^11.5.0", | ||
| "nyc": "^15.1.0", | ||
| "rimraf": "^2.4.1", | ||
@@ -38,0 +39,0 @@ "standard": "^14.3.3", |
+35
-20
@@ -1,2 +0,2 @@ | ||
| # Multer [](https://github.com/expressjs/multer/actions/workflows/ci.yml) [](https://coveralls.io/r/expressjs/multer?branch=master) [](https://badge.fury.io/js/multer) [](https://github.com/feross/standard) | ||
| # Multer [![NPM Version][npm-version-image]][npm-url] [![NPM Downloads][npm-downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Test Coverage][test-image]][test-url] [![OpenSSF Scorecard Badge][ossf-scorecard-badge]][ossf-scorecard-visualizer] | ||
@@ -8,12 +8,17 @@ Multer is a node.js middleware for handling `multipart/form-data`, which is primarily used for uploading files. It is written | ||
| ## Translations | ||
| ## Translations | ||
| This README is also available in other languages: | ||
| - [Español](https://github.com/expressjs/multer/blob/master/doc/README-es.md) (Spanish) | ||
| - [简体中文](https://github.com/expressjs/multer/blob/master/doc/README-zh-cn.md) (Chinese) | ||
| - [한국어](https://github.com/expressjs/multer/blob/master/doc/README-ko.md) (Korean) | ||
| - [Русский язык](https://github.com/expressjs/multer/blob/master/doc/README-ru.md) (Russian) | ||
| - [Việt Nam](https://github.com/expressjs/multer/blob/master/doc/README-vi.md) (Vietnam) | ||
| - [Português](https://github.com/expressjs/multer/blob/master/doc/README-pt-br.md) (Portuguese Brazil) | ||
| | | | | ||
| | ------------------------------------------------------------------------------ | --------------- | | ||
| | [العربية](https://github.com/expressjs/multer/blob/main/doc/README-ar.md) | Arabic | | ||
| | [简体中文](https://github.com/expressjs/multer/blob/main/doc/README-zh-cn.md) | Chinese | | ||
| | [Français](https://github.com/expressjs/multer/blob/main/doc/README-fr.md) | French | | ||
| | [한국어](https://github.com/expressjs/multer/blob/main/doc/README-ko.md) | Korean | | ||
| | [Português](https://github.com/expressjs/multer/blob/main/doc/README-pt-br.md) | Portuguese (BR) | | ||
| | [Русский язык](https://github.com/expressjs/multer/blob/main/doc/README-ru.md) | Russian | | ||
| | [Español](https://github.com/expressjs/multer/blob/main/doc/README-es.md) | Spanish | | ||
| | [O'zbek tili](https://github.com/expressjs/multer/blob/main/doc/README-uz.md) | Uzbek | | ||
| | [Việt Nam](https://github.com/expressjs/multer/blob/main/doc/README-vi.md) | Vietnamese | | ||
@@ -23,3 +28,3 @@ ## Installation | ||
| ```sh | ||
| $ npm install --save multer | ||
| $ npm install multer | ||
| ``` | ||
@@ -58,4 +63,4 @@ | ||
| const cpUpload = upload.fields([{ name: 'avatar', maxCount: 1 }, { name: 'gallery', maxCount: 8 }]) | ||
| app.post('/cool-profile', cpUpload, function (req, res, next) { | ||
| const uploadMiddleware = upload.fields([{ name: 'avatar', maxCount: 1 }, { name: 'gallery', maxCount: 8 }]) | ||
| app.post('/cool-profile', uploadMiddleware, function (req, res, next) { | ||
| // req.files is an object (String -> Array) where fieldname is the key, and the value is array of files | ||
@@ -84,3 +89,3 @@ // | ||
| Here's an example on how multer is used an HTML form. Take special note of the `enctype="multipart/form-data"` and `name="uploaded_file"` fields: | ||
| Here's an example on how multer is used in a HTML form. Take special note of the `enctype="multipart/form-data"` and `name="uploaded_file"` fields: | ||
@@ -92,3 +97,3 @@ ```html | ||
| <input type="text" class="form-control" placeholder="Number of speakers" name="nspeakers"> | ||
| <input type="submit" value="Get me the stats!" class="btn btn-default"> | ||
| <input type="submit" value="Get me the stats!" class="btn btn-default"> | ||
| </div> | ||
@@ -104,5 +109,5 @@ </form> | ||
| app.post('/stats', upload.single('uploaded_file'), function (req, res) { | ||
| // req.file is the name of your file in the form above, here 'uploaded_file' | ||
| // req.body will hold the text fields, if there were any | ||
| console.log(req.file, req.body) | ||
| // req.file is the name of your file in the form above, here 'uploaded_file' | ||
| // req.body will hold the text fields, if there were any | ||
| console.log(req.file, req.body) | ||
| }); | ||
@@ -238,3 +243,3 @@ ``` | ||
| **Note:** Multer will not append any file extension for you, your function | ||
| should return a filename complete with an file extension. | ||
| should return a filename complete with a file extension. | ||
@@ -249,3 +254,3 @@ Each function gets passed both the request (`req`) and some information about | ||
| null as the first param), refer to | ||
| [Node.js error handling](https://www.joyent.com/node-js/production/design/errors) | ||
| [Node.js error handling](https://web.archive.org/web/20220417042018/https://www.joyent.com/node-js/production/design/errors) | ||
@@ -316,3 +321,3 @@ #### `MemoryStorage` | ||
| If you want to catch errors specifically from Multer, you can call the | ||
| middleware function by yourself. Also, if you want to catch only [the Multer errors](https://github.com/expressjs/multer/blob/master/lib/multer-error.js), you can use the `MulterError` class that is attached to the `multer` object itself (e.g. `err instanceof multer.MulterError`). | ||
| middleware function by yourself. Also, if you want to catch only [the Multer errors](https://github.com/expressjs/multer/blob/main/lib/multer-error.js), you can use the `MulterError` class that is attached to the `multer` object itself (e.g. `err instanceof multer.MulterError`). | ||
@@ -338,3 +343,3 @@ ```javascript | ||
| For information on how to build your own storage engine, see [Multer Storage Engine](https://github.com/expressjs/multer/blob/master/StorageEngine.md). | ||
| For information on how to build your own storage engine, see [Multer Storage Engine](https://github.com/expressjs/multer/blob/main/StorageEngine.md). | ||
@@ -344,1 +349,11 @@ ## License | ||
| [MIT](LICENSE) | ||
| [ci-image]: https://github.com/expressjs/multer/actions/workflows/ci.yml/badge.svg | ||
| [ci-url]: https://github.com/expressjs/multer/actions/workflows/ci.yml | ||
| [test-url]: https://coveralls.io/r/expressjs/multer?branch=main | ||
| [test-image]: https://badgen.net/coveralls/c/github/expressjs/multer/main | ||
| [npm-downloads-image]: https://badgen.net/npm/dm/multer | ||
| [npm-url]: https://npmjs.org/package/multer | ||
| [npm-version-image]: https://badgen.net/npm/v/multer | ||
| [ossf-scorecard-badge]: https://api.scorecard.dev/projects/github.com/expressjs/multer/badge | ||
| [ossf-scorecard-visualizer]: https://ossf.github.io/scorecard-visualizer/#/projects/github.com/expressjs/multer |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
29362
3.83%424
0.24%348
4.19%0
-100%9
12.5%+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated
Updated
Updated