Cleanup
This commit is contained in:
72
node_modules/multer/CHANGELOG.md
generated
vendored
72
node_modules/multer/CHANGELOG.md
generated
vendored
@@ -1,72 +0,0 @@
|
||||
# Change log
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## 1.4.2 - 2019-07-16
|
||||
|
||||
- Docs: Add Russian translation for README (#662)
|
||||
- Docs: Patch zh-CN README base on newest README (#670)
|
||||
- Docs: Fix broken link in Readme (#679)
|
||||
- Docs: Fix broken link in Chinese Readme (#730)
|
||||
- Docs: Fix typo in Russian README (#738)
|
||||
- Docs: Add unit for fieldSize in busboy limit params (#734)
|
||||
- Internal: Make unit tests comaptible with Node.js 13.x (#752)
|
||||
|
||||
## 1.4.1 - 2018-10-11
|
||||
|
||||
- Bugfix: Make sure that req.file.buffer always is a Buffer
|
||||
|
||||
## 1.4.0 - 2018-09-26
|
||||
|
||||
- Feature: Make Multer errors inherit from MulterError
|
||||
|
||||
## 1.3.1 - 2018-06-28
|
||||
|
||||
- Bugfix: Bump vulnerable dependency
|
||||
|
||||
## 1.3.0 - 2017-01-25
|
||||
|
||||
- Feature: Expose preservePath option
|
||||
|
||||
## 1.2.1 - 2016-12-14
|
||||
|
||||
- Bugfix: Prevent Multiple Errors from Crashing
|
||||
|
||||
## 1.2.0 - 2016-08-04
|
||||
|
||||
- Feature: add .none() for accepting only fields
|
||||
|
||||
## 1.1.0 - 2015-10-23
|
||||
|
||||
- Feature: accept any file, regardless of fieldname
|
||||
|
||||
## 1.0.6 - 2015-10-03
|
||||
|
||||
- Bugfix: always report limit errors
|
||||
|
||||
## 1.0.5 - 2015-09-19
|
||||
|
||||
- Bugfix: drain the stream before considering request done
|
||||
|
||||
## 1.0.4 - 2015-09-19
|
||||
|
||||
- Bugfix: propagate all errors from busboy
|
||||
|
||||
## 1.0.3 - 2015-08-06
|
||||
|
||||
- Bugfix: ensure file order is correct
|
||||
|
||||
## 1.0.2 - 2015-08-06
|
||||
|
||||
- Bugfix: don't hang when hitting size limit
|
||||
|
||||
## 1.0.1 - 2015-07-20
|
||||
|
||||
- Bugfix: decrement pending writes on error
|
||||
|
||||
## 1.0.0 - 2015-07-18
|
||||
|
||||
- Introduce storage engines
|
||||
- Specify expected fields
|
||||
- Follow the W3C JSON form spec
|
||||
68
node_modules/multer/README.md
generated
vendored
68
node_modules/multer/README.md
generated
vendored
@@ -9,9 +9,12 @@ on top of [busboy](https://github.com/mscdex/busboy) for maximum efficiency.
|
||||
|
||||
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)
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -34,11 +37,11 @@ Don't forget the `enctype="multipart/form-data"` in your form.
|
||||
```
|
||||
|
||||
```javascript
|
||||
var express = require('express')
|
||||
var multer = require('multer')
|
||||
var upload = multer({ dest: 'uploads/' })
|
||||
const express = require('express')
|
||||
const multer = require('multer')
|
||||
const upload = multer({ dest: 'uploads/' })
|
||||
|
||||
var app = express()
|
||||
const app = express()
|
||||
|
||||
app.post('/profile', upload.single('avatar'), function (req, res, next) {
|
||||
// req.file is the `avatar` file
|
||||
@@ -50,7 +53,7 @@ app.post('/photos/upload', upload.array('photos', 12), function (req, res, next)
|
||||
// req.body will contain the text fields, if there were any
|
||||
})
|
||||
|
||||
var cpUpload = upload.fields([{ name: 'avatar', maxCount: 1 }, { name: 'gallery', maxCount: 8 }])
|
||||
const cpUpload = upload.fields([{ name: 'avatar', maxCount: 1 }, { name: 'gallery', maxCount: 8 }])
|
||||
app.post('/cool-profile', cpUpload, function (req, res, next) {
|
||||
// req.files is an object (String -> Array) where fieldname is the key, and the value is array of files
|
||||
//
|
||||
@@ -65,16 +68,42 @@ app.post('/cool-profile', cpUpload, function (req, res, next) {
|
||||
In case you need to handle a text-only multipart form, you should use the `.none()` method:
|
||||
|
||||
```javascript
|
||||
var express = require('express')
|
||||
var app = express()
|
||||
var multer = require('multer')
|
||||
var upload = multer()
|
||||
const express = require('express')
|
||||
const app = express()
|
||||
const multer = require('multer')
|
||||
const upload = multer()
|
||||
|
||||
app.post('/profile', upload.none(), function (req, res, next) {
|
||||
// req.body contains the text fields
|
||||
})
|
||||
```
|
||||
|
||||
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:
|
||||
|
||||
```html
|
||||
<form action="/stats" enctype="multipart/form-data" method="post">
|
||||
<div class="form-group">
|
||||
<input type="file" class="form-control-file" name="uploaded_file">
|
||||
<input type="text" class="form-control" placeholder="Number of speakers" name="nspeakers">
|
||||
<input type="submit" value="Get me the stats!" class="btn btn-default">
|
||||
</div>
|
||||
</form>
|
||||
```
|
||||
|
||||
Then in your javascript file you would add these lines to access both the file and the body. It is important that you use the `name` field value from the form in your upload function. This tells multer which field on the request it should look for the files in. If these fields aren't the same in the HTML form and on your server, your upload will fail:
|
||||
|
||||
```javascript
|
||||
const multer = require('multer')
|
||||
const upload = multer({ dest: './public/data/uploads/' })
|
||||
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)
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### File information
|
||||
@@ -115,7 +144,7 @@ In an average web app, only `dest` might be required, and configured as shown in
|
||||
the following example.
|
||||
|
||||
```javascript
|
||||
var upload = multer({ dest: 'uploads/' })
|
||||
const upload = multer({ dest: 'uploads/' })
|
||||
```
|
||||
|
||||
If you want more control over your uploads, you'll want to use the `storage`
|
||||
@@ -170,16 +199,17 @@ where you are handling the uploaded files.
|
||||
The disk storage engine gives you full control on storing files to disk.
|
||||
|
||||
```javascript
|
||||
var storage = multer.diskStorage({
|
||||
const storage = multer.diskStorage({
|
||||
destination: function (req, file, cb) {
|
||||
cb(null, '/tmp/my-uploads')
|
||||
},
|
||||
filename: function (req, file, cb) {
|
||||
cb(null, file.fieldname + '-' + Date.now())
|
||||
const uniqueSuffix = Date.now() + '-' + Math.round(Math.random() * 1E9)
|
||||
cb(null, file.fieldname + '-' + uniqueSuffix)
|
||||
}
|
||||
})
|
||||
|
||||
var upload = multer({ storage: storage })
|
||||
const upload = multer({ storage: storage })
|
||||
```
|
||||
|
||||
There are two options available, `destination` and `filename`. They are both
|
||||
@@ -207,14 +237,18 @@ the file (`file`) to aid with the decision.
|
||||
Note that `req.body` might not have been fully populated yet. It depends on the
|
||||
order that the client transmits fields and files to the server.
|
||||
|
||||
For understanding the calling convention used in the callback (needing to pass
|
||||
null as the first param), refer to
|
||||
[Node.js error handling](https://www.joyent.com/node-js/production/design/errors)
|
||||
|
||||
#### `MemoryStorage`
|
||||
|
||||
The memory storage engine stores the files in memory as `Buffer` objects. It
|
||||
doesn't have any options.
|
||||
|
||||
```javascript
|
||||
var storage = multer.memoryStorage()
|
||||
var upload = multer({ storage: storage })
|
||||
const storage = multer.memoryStorage()
|
||||
const upload = multer({ storage: storage })
|
||||
```
|
||||
|
||||
When using memory storage, the file info will contain a field called
|
||||
@@ -274,8 +308,8 @@ 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`).
|
||||
|
||||
```javascript
|
||||
var multer = require('multer')
|
||||
var upload = multer().single('avatar')
|
||||
const multer = require('multer')
|
||||
const upload = multer().single('avatar')
|
||||
|
||||
app.post('/profile', function (req, res) {
|
||||
upload(req, res, function (err) {
|
||||
|
||||
5
node_modules/multer/lib/make-middleware.js
generated
vendored
5
node_modules/multer/lib/make-middleware.js
generated
vendored
@@ -81,11 +81,12 @@ function makeMiddleware (setup) {
|
||||
|
||||
// handle text field data
|
||||
busboy.on('field', function (fieldname, value, fieldnameTruncated, valueTruncated) {
|
||||
if (fieldname == null) return abortWithCode('MISSING_FIELD_NAME')
|
||||
if (fieldnameTruncated) return abortWithCode('LIMIT_FIELD_KEY')
|
||||
if (valueTruncated) return abortWithCode('LIMIT_FIELD_VALUE', fieldname)
|
||||
|
||||
// Work around bug in Busboy (https://github.com/mscdex/busboy/issues/6)
|
||||
if (limits && limits.hasOwnProperty('fieldNameSize')) {
|
||||
if (limits && Object.prototype.hasOwnProperty.call(limits, 'fieldNameSize')) {
|
||||
if (fieldname.length > limits.fieldNameSize) return abortWithCode('LIMIT_FIELD_KEY')
|
||||
}
|
||||
|
||||
@@ -98,7 +99,7 @@ function makeMiddleware (setup) {
|
||||
if (!filename) return fileStream.resume()
|
||||
|
||||
// Work around bug in Busboy (https://github.com/mscdex/busboy/issues/6)
|
||||
if (limits && limits.hasOwnProperty('fieldNameSize')) {
|
||||
if (limits && Object.prototype.hasOwnProperty.call(limits, 'fieldNameSize')) {
|
||||
if (fieldname.length > limits.fieldNameSize) return abortWithCode('LIMIT_FIELD_KEY')
|
||||
}
|
||||
|
||||
|
||||
15
node_modules/multer/lib/multer-error.js
generated
vendored
15
node_modules/multer/lib/multer-error.js
generated
vendored
@@ -1,13 +1,14 @@
|
||||
var util = require('util')
|
||||
|
||||
var errorMessages = {
|
||||
'LIMIT_PART_COUNT': 'Too many parts',
|
||||
'LIMIT_FILE_SIZE': 'File too large',
|
||||
'LIMIT_FILE_COUNT': 'Too many files',
|
||||
'LIMIT_FIELD_KEY': 'Field name too long',
|
||||
'LIMIT_FIELD_VALUE': 'Field value too long',
|
||||
'LIMIT_FIELD_COUNT': 'Too many fields',
|
||||
'LIMIT_UNEXPECTED_FILE': 'Unexpected field'
|
||||
LIMIT_PART_COUNT: 'Too many parts',
|
||||
LIMIT_FILE_SIZE: 'File too large',
|
||||
LIMIT_FILE_COUNT: 'Too many files',
|
||||
LIMIT_FIELD_KEY: 'Field name too long',
|
||||
LIMIT_FIELD_VALUE: 'Field value too long',
|
||||
LIMIT_FIELD_COUNT: 'Too many fields',
|
||||
LIMIT_UNEXPECTED_FILE: 'Unexpected field',
|
||||
MISSING_FIELD_NAME: 'Field name missing'
|
||||
}
|
||||
|
||||
function MulterError (code, field) {
|
||||
|
||||
13
node_modules/multer/package.json
generated
vendored
13
node_modules/multer/package.json
generated
vendored
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "multer",
|
||||
"description": "Middleware for handling `multipart/form-data`.",
|
||||
"version": "1.4.2",
|
||||
"version": "1.4.4",
|
||||
"contributors": [
|
||||
"Hage Yaapa <captain@hacksparrow.com> (http://www.hacksparrow.com)",
|
||||
"Jaret Pfluger <https://github.com/jpfluger>",
|
||||
@@ -22,19 +22,20 @@
|
||||
"append-field": "^1.0.0",
|
||||
"busboy": "^0.2.11",
|
||||
"concat-stream": "^1.5.2",
|
||||
"mkdirp": "^0.5.1",
|
||||
"mkdirp": "^0.5.4",
|
||||
"object-assign": "^4.1.1",
|
||||
"on-finished": "^2.3.0",
|
||||
"type-is": "^1.6.4",
|
||||
"xtend": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"deep-equal": "^2.0.3",
|
||||
"express": "^4.13.1",
|
||||
"form-data": "^1.0.0-rc1",
|
||||
"fs-temp": "^1.1.2",
|
||||
"mocha": "^3.5.3",
|
||||
"rimraf": "^2.4.1",
|
||||
"standard": "^11.0.1",
|
||||
"standard": "^14.3.3",
|
||||
"testdata-w3c-json-form": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
@@ -49,8 +50,4 @@
|
||||
"scripts": {
|
||||
"test": "standard && mocha"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/multer/-/multer-1.4.2.tgz"
|
||||
,"_integrity": "sha512-xY8pX7V+ybyUpbYMxtjM9KAiD9ixtg5/JkeKUTD6xilfDv0vzzOFcCp4Ljb1UU3tSOM3VTZtKo63OmzOrGi3Cg=="
|
||||
,"_from": "multer@1.4.2"
|
||||
}
|
||||
}
|
||||
|
||||
2
node_modules/multer/storage/disk.js
generated
vendored
2
node_modules/multer/storage/disk.js
generated
vendored
@@ -5,7 +5,7 @@ var crypto = require('crypto')
|
||||
var mkdirp = require('mkdirp')
|
||||
|
||||
function getFilename (req, file, cb) {
|
||||
crypto.pseudoRandomBytes(16, function (err, raw) {
|
||||
crypto.randomBytes(16, function (err, raw) {
|
||||
cb(err, err ? undefined : raw.toString('hex'))
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user