????JFIF??x?x????'
Server IP : 79.136.114.73 / Your IP : 18.220.44.17 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/appsrv.astacus.se/forge/node_modules/multer/ |
Upload File : |
{ "name": "multer", "description": "Middleware for handling `multipart/form-data`.", "version": "1.4.3", "contributors": [ { "name": "Hage Yaapa", "email": "captain@hacksparrow.com", "url": "http://www.hacksparrow.com" }, { "name": "Jaret Pfluger", "email": "https://github.com/jpfluger" }, { "name": "Linus Unnebäck", "email": "linus@folkdatorn.se" } ], "license": "MIT", "repository": { "type": "git", "url": "git://github.com/expressjs/multer" }, "keywords": [ "form", "post", "multipart", "form-data", "formdata", "express", "middleware" ], "dependencies": { "append-field": "^1.0.0", "busboy": "^0.2.11", "concat-stream": "^1.5.2", "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": "^14.3.3", "testdata-w3c-json-form": "^1.0.0" }, "engines": { "node": ">= 0.10.0" }, "files": [ "LICENSE", "index.js", "storage/", "lib/" ], "scripts": { "test": "standard && mocha" }, "readme": "# Multer [](https://travis-ci.org/expressjs/multer) [](https://badge.fury.io/js/multer) [](https://github.com/feross/standard)\n\nMulter is a node.js middleware for handling `multipart/form-data`, which is primarily used for uploading files. It is written\non top of [busboy](https://github.com/mscdex/busboy) for maximum efficiency.\n\n**NOTE**: Multer will not process any form which is not multipart (`multipart/form-data`).\n\n## Translations \n\nThis README is also available in other languages:\n\n- [简体中文](https://github.com/expressjs/multer/blob/master/doc/README-zh-cn.md) (Chinese)\n- [한국어](https://github.com/expressjs/multer/blob/master/doc/README-ko.md) (Korean)\n- [Русский язык](https://github.com/expressjs/multer/blob/master/doc/README-ru.md) (Russian)\n- [Português](https://github.com/expressjs/multer/blob/master/doc/README-pt-br.md) (Português Brazil)\n\n## Installation\n\n```sh\n$ npm install --save multer\n```\n\n## Usage\n\nMulter adds a `body` object and a `file` or `files` object to the `request` object. The `body` object contains the values of the text fields of the form, the `file` or `files` object contains the files uploaded via the form.\n\nBasic usage example:\n\nDon't forget the `enctype=\"multipart/form-data\"` in your form.\n\n```html\n<form action=\"/profile\" method=\"post\" enctype=\"multipart/form-data\">\n <input type=\"file\" name=\"avatar\" />\n</form>\n```\n\n```javascript\nconst express = require('express')\nconst multer = require('multer')\nconst upload = multer({ dest: 'uploads/' })\n\nconst app = express()\n\napp.post('/profile', upload.single('avatar'), function (req, res, next) {\n // req.file is the `avatar` file\n // req.body will hold the text fields, if there were any\n})\n\napp.post('/photos/upload', upload.array('photos', 12), function (req, res, next) {\n // req.files is array of `photos` files\n // req.body will contain the text fields, if there were any\n})\n\nconst cpUpload = upload.fields([{ name: 'avatar', maxCount: 1 }, { name: 'gallery', maxCount: 8 }])\napp.post('/cool-profile', cpUpload, function (req, res, next) {\n // req.files is an object (String -> Array) where fieldname is the key, and the value is array of files\n //\n // e.g.\n // req.files['avatar'][0] -> File\n // req.files['gallery'] -> Array\n //\n // req.body will contain the text fields, if there were any\n})\n```\n\nIn case you need to handle a text-only multipart form, you should use the `.none()` method:\n\n```javascript\nconst express = require('express')\nconst app = express()\nconst multer = require('multer')\nconst upload = multer()\n\napp.post('/profile', upload.none(), function (req, res, next) {\n // req.body contains the text fields\n})\n```\n\nHere'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:\n\n```html\n<form action=\"/stats\" enctype=\"multipart/form-data\" method=\"post\">\n <div class=\"form-group\">\n <input type=\"file\" class=\"form-control-file\" name=\"uploaded_file\">\n <input type=\"text\" class=\"form-control\" placeholder=\"Number of speakers\" name=\"nspeakers\">\n <input type=\"submit\" value=\"Get me the stats!\" class=\"btn btn-default\"> \n </div>\n</form>\n```\n\nThen 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:\n\n```javascript\nconst multer = require('multer')\nconst upload = multer({ dest: './public/data/uploads/' })\napp.post('/stats', upload.single('uploaded_file'), function (req, res) {\n // req.file is the name of your file in the form above, here 'uploaded_file'\n // req.body will hold the text fields, if there were any \n console.log(req.file, req.body)\n});\n```\n\n\n\n## API\n\n### File information\n\nEach file contains the following information:\n\nKey | Description | Note\n--- | --- | ---\n`fieldname` | Field name specified in the form |\n`originalname` | Name of the file on the user's computer |\n`encoding` | Encoding type of the file |\n`mimetype` | Mime type of the file |\n`size` | Size of the file in bytes |\n`destination` | The folder to which the file has been saved | `DiskStorage`\n`filename` | The name of the file within the `destination` | `DiskStorage`\n`path` | The full path to the uploaded file | `DiskStorage`\n`buffer` | A `Buffer` of the entire file | `MemoryStorage`\n\n### `multer(opts)`\n\nMulter accepts an options object, the most basic of which is the `dest`\nproperty, which tells Multer where to upload the files. In case you omit the\noptions object, the files will be kept in memory and never written to disk.\n\nBy default, Multer will rename the files so as to avoid naming conflicts. The\nrenaming function can be customized according to your needs.\n\nThe following are the options that can be passed to Multer.\n\nKey | Description\n--- | ---\n`dest` or `storage` | Where to store the files\n`fileFilter` | Function to control which files are accepted\n`limits` | Limits of the uploaded data\n`preservePath` | Keep the full path of files instead of just the base name\n\nIn an average web app, only `dest` might be required, and configured as shown in\nthe following example.\n\n```javascript\nconst upload = multer({ dest: 'uploads/' })\n```\n\nIf you want more control over your uploads, you'll want to use the `storage`\noption instead of `dest`. Multer ships with storage engines `DiskStorage`\nand `MemoryStorage`; More engines are available from third parties.\n\n#### `.single(fieldname)`\n\nAccept a single file with the name `fieldname`. The single file will be stored\nin `req.file`.\n\n#### `.array(fieldname[, maxCount])`\n\nAccept an array of files, all with the name `fieldname`. Optionally error out if\nmore than `maxCount` files are uploaded. The array of files will be stored in\n`req.files`.\n\n#### `.fields(fields)`\n\nAccept a mix of files, specified by `fields`. An object with arrays of files\nwill be stored in `req.files`.\n\n`fields` should be an array of objects with `name` and optionally a `maxCount`.\nExample:\n\n```javascript\n[\n { name: 'avatar', maxCount: 1 },\n { name: 'gallery', maxCount: 8 }\n]\n```\n\n#### `.none()`\n\nAccept only text fields. If any file upload is made, error with code\n\"LIMIT\\_UNEXPECTED\\_FILE\" will be issued.\n\n#### `.any()`\n\nAccepts all files that comes over the wire. An array of files will be stored in\n`req.files`.\n\n**WARNING:** Make sure that you always handle the files that a user uploads.\nNever add multer as a global middleware since a malicious user could upload\nfiles to a route that you didn't anticipate. Only use this function on routes\nwhere you are handling the uploaded files.\n\n### `storage`\n\n#### `DiskStorage`\n\nThe disk storage engine gives you full control on storing files to disk.\n\n```javascript\nconst storage = multer.diskStorage({\n destination: function (req, file, cb) {\n cb(null, '/tmp/my-uploads')\n },\n filename: function (req, file, cb) {\n const uniqueSuffix = Date.now() + '-' + Math.round(Math.random() * 1E9)\n cb(null, file.fieldname + '-' + uniqueSuffix)\n }\n})\n\nconst upload = multer({ storage: storage })\n```\n\nThere are two options available, `destination` and `filename`. They are both\nfunctions that determine where the file should be stored.\n\n`destination` is used to determine within which folder the uploaded files should\nbe stored. This can also be given as a `string` (e.g. `'/tmp/uploads'`). If no\n`destination` is given, the operating system's default directory for temporary\nfiles is used.\n\n**Note:** You are responsible for creating the directory when providing\n`destination` as a function. When passing a string, multer will make sure that\nthe directory is created for you.\n\n`filename` is used to determine what the file should be named inside the folder.\nIf no `filename` is given, each file will be given a random name that doesn't\ninclude any file extension.\n\n**Note:** Multer will not append any file extension for you, your function\nshould return a filename complete with an file extension.\n\nEach function gets passed both the request (`req`) and some information about\nthe file (`file`) to aid with the decision.\n\nNote that `req.body` might not have been fully populated yet. It depends on the\norder that the client transmits fields and files to the server.\n\nFor understanding the calling convention used in the callback (needing to pass\nnull as the first param), refer to\n[Node.js error handling](https://www.joyent.com/node-js/production/design/errors)\n\n#### `MemoryStorage`\n\nThe memory storage engine stores the files in memory as `Buffer` objects. It\ndoesn't have any options.\n\n```javascript\nconst storage = multer.memoryStorage()\nconst upload = multer({ storage: storage })\n```\n\nWhen using memory storage, the file info will contain a field called\n`buffer` that contains the entire file.\n\n**WARNING**: Uploading very large files, or relatively small files in large\nnumbers very quickly, can cause your application to run out of memory when\nmemory storage is used.\n\n### `limits`\n\nAn object specifying the size limits of the following optional properties. Multer passes this object into busboy directly, and the details of the properties can be found on [busboy's page](https://github.com/mscdex/busboy#busboy-methods).\n\nThe following integer values are available:\n\nKey | Description | Default\n--- | --- | ---\n`fieldNameSize` | Max field name size | 100 bytes\n`fieldSize` | Max field value size (in bytes) | 1MB\n`fields` | Max number of non-file fields | Infinity\n`fileSize` | For multipart forms, the max file size (in bytes) | Infinity\n`files` | For multipart forms, the max number of file fields | Infinity\n`parts` | For multipart forms, the max number of parts (fields + files) | Infinity\n`headerPairs` | For multipart forms, the max number of header key=>value pairs to parse | 2000\n\nSpecifying the limits can help protect your site against denial of service (DoS) attacks.\n\n### `fileFilter`\n\nSet this to a function to control which files should be uploaded and which\nshould be skipped. The function should look like this:\n\n```javascript\nfunction fileFilter (req, file, cb) {\n\n // The function should call `cb` with a boolean\n // to indicate if the file should be accepted\n\n // To reject this file pass `false`, like so:\n cb(null, false)\n\n // To accept the file pass `true`, like so:\n cb(null, true)\n\n // You can always pass an error if something goes wrong:\n cb(new Error('I don\\'t have a clue!'))\n\n}\n```\n\n## Error handling\n\nWhen encountering an error, Multer will delegate the error to Express. You can\ndisplay a nice error page using [the standard express way](http://expressjs.com/guide/error-handling.html).\n\nIf you want to catch errors specifically from Multer, you can call the\nmiddleware 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`).\n\n```javascript\nconst multer = require('multer')\nconst upload = multer().single('avatar')\n\napp.post('/profile', function (req, res) {\n upload(req, res, function (err) {\n if (err instanceof multer.MulterError) {\n // A Multer error occurred when uploading.\n } else if (err) {\n // An unknown error occurred when uploading.\n }\n\n // Everything went fine.\n })\n})\n```\n\n## Custom storage engine\n\nFor information on how to build your own storage engine, see [Multer Storage Engine](https://github.com/expressjs/multer/blob/master/StorageEngine.md).\n\n## License\n\n[MIT](LICENSE)\n", "readmeFilename": "README.md", "bugs": { "url": "https://github.com/expressjs/multer/issues" }, "_id": "multer@1.4.3", "dist": { "shasum": "7ccaf4fa70ff3fe5f57568c9a9d24f776481e491" }, "_from": "multer@^1.4.0", "_resolved": "http://registry.npmjs.org/multer/-/multer-1.4.3.tgz" }