forked from arvindr21/blueimp-file-upload-expressjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.json
47 lines (47 loc) · 10.3 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{
"name": "blueimp-file-upload-expressjs",
"version": "0.4.5",
"description": "jQuery File Upload using Expressjs : 'borrowed' from Blueimp jQuery File Upload developed by Sebastian Tschan",
"main": "index.js",
"scripts": {
"test": "jasmine-node specs/"
},
"dependencies": {
"async": "^0.9.0",
"aws-sdk": "^2.1.20",
"formidable": "^1.0.17",
"lwip": "~0.0.8",
"mkdirp": "0.5.0"
},
"devDependencies": {
"gulp": "^3.8.11",
"gulp-jshint": "^1.9.4",
"jasmine-node": "1.14.2",
"jshint-stylish": "^1.0.1"
},
"repository": {
"type": "git",
"url": "https://github.com/arvindr21/blueimp-file-upload-expressjs.git"
},
"keywords": [
"jQuery",
"file",
"upload",
"expressjs"
],
"author": {
"name": "Arvind Ravulavaru"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/arvindr21/blueimp-file-upload-expressjs/issues"
},
"homepage": "https://github.com/arvindr21/blueimp-file-upload-expressjs",
"gitHead": "eb370db8c5c79475a56d25972dc33e2172b0a4ef",
"readme": "# Blueimp file upload for Express js\n\n[![Build Status](https://travis-ci.org/arvindr21/blueimp-file-upload-expressjs.svg?branch=master)](https://travis-ci.org/arvindr21/blueimp-file-upload-expressjs) [![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/arvindr21/blueimp-file-upload-expressjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)\n\n[![NPM](https://nodei.co/npm/blueimp-file-upload-expressjs.png?downloads=true)](https://nodei.co/npm/blueimp-file-upload-expressjs/)\n\nA simple express module for integrating the *[jQuery File Upload](http://blueimp.github.io/jQuery-File-Upload/)* frontend plugin.\n\n[Fullstack Demo](http://expressjs-fileupload.cloudno.de/) | [Tutorial on my blog](http://thejackalofjavascript.com/uploading-files-made-fun)\n\n## History\nThe code was forked from a sample backend code from the [plugin's repo](https://github.com/blueimp/jQuery-File-Upload/tree/master/server/node). Adaptations were made to show how to use this plugin with the popular *[Express](http://expressjs.com/)* *Node.js* framework.\n\nAlthough this code was initially meant for educational purposes, enhancements were made. Users can additionally:\n\n* choose the destination filesystem, local or cloud-based *Amazon S3*,\n* create thumbnail without heavy external dependencies using [lwip](https://www.npmjs.com/package/lwip),\n* setup server-side rules by [configuration](#Configuration),\n* modify the code against a [test harness](#Tests). \n\n## Installation\n\nSetup an *Express* project and install the package.\n\n```js\n$ npm install blueimp-file-upload-expressjs\n```\n\nBeginners can follow the [tutorial](http://thejackalofjavascript.com/uploading-files-made-fun) for detailed instructions.\n\n## Tests\n\nUnit tests can be run with *Jasmine* using `npm test` or this command:\n```js\n$ jasmine-node specs/\n```\n\nManual end to end tests can be done with [this full project](https://github.com/arvindr21/expressjs-fileupload). Change the `require()` path of [`uploadManager.js`](https://github.com/arvindr21/expressjs-fileupload/blob/master/routes/uploadManager.js#L29) to link it this cloned repository.\n\n## Configuration\n```js\noptions = {\n tmpDir: __dirname + '/tmp', // tmp dir to upload files to\n uploadDir: __dirname + '/public/files', // actual location of the file\n uploadUrl: '/files/', // end point for delete route \n maxPostSize: 11000000000, // 11 GB\n minFileSize: 1,\n maxFileSize: 10000000000, // 10 GB\n acceptFileTypes: /.+/i,\n inlineFileTypes: /\\.(gif|jpe?g|png)/i,\n imageTypes: /\\.(gif|jpe?g|png)/i,\n copyImgAsThumb : true, // required\n imageVersions :{\n maxWidth : 200,\n maxHeight : 200\n },\n accessControl: {\n allowOrigin: '*',\n allowMethods: 'OPTIONS, HEAD, GET, POST, PUT, DELETE',\n allowHeaders: 'Content-Type, Content-Range, Content-Disposition'\n },\n storage : {\n type : 'local', // local or aws\n aws : {\n accessKeyId : 'xxxxxxxxxxxxxxxxx', // required if aws\n secretAccessKey : 'xxxxxxxxxxxxxxxxxxxxxxx', // required if aws\n region : 'us-west-2', //make sure you know the region, else leave this option out\n bucketName : 'xxxxxxxxx' // required if aws\n }\n }\n};\n\n```\n### Usage with options \n(*refer tutorial*)\n```js\n// config the uploader\nvar options = {\n tmpDir: __dirname + '/../public/uploaded/tmp',\n uploadDir: __dirname + '/../public/uploaded/files',\n uploadUrl: '/uploaded/files/',\n maxPostSize: 11000000000, // 11 GB\n minFileSize: 1,\n maxFileSize: 10000000000, // 10 GB\n acceptFileTypes: /.+/i,\n // Files not matched by this regular expression force a download dialog,\n // to prevent executing any scripts in the context of the service domain:\n inlineFileTypes: /\\.(gif|jpe?g|png)/i,\n imageTypes: /\\.(gif|jpe?g|png)/i,\n copyImgAsThumb : true, // required\n imageVersions :{\n maxWidth : 200,\n maxHeight : 200\n },\n accessControl: {\n allowOrigin: '*',\n allowMethods: 'OPTIONS, HEAD, GET, POST, PUT, DELETE',\n allowHeaders: 'Content-Type, Content-Range, Content-Disposition'\n },\n storage : {\n type : 'aws',\n aws : {\n accessKeyId : 'xxxxxxxxxxxxxxxxx',\n secretAccessKey : 'xxxxxxxxxxxxxxxxx',\n region : 'us-east-1',//make sure you know the region, else leave this option out\n bucketName : 'xxxxxxxxxxxxxxxxx'\n }\n }\n};\n\n// init the uploader\nvar uploader = require('blueimp-file-upload-expressjs')(options);\n\n\nmodule.exports = function (router) {\n router.get('/upload', function(req, res) {\n uploader.get(req, res, function (err,obj) {\n if(!err){\n res.send(JSON.stringify(obj));\n }\n });\n \n });\n\n router.post('/upload', function(req, res) {\n uploader.post(req, res, function (error,obj, redirect) {\n if(!error)\n {\n res.send(JSON.stringify(obj)); \n }\n });\n \n });\n \n // the path SHOULD match options.uploadUrl\n router.delete('/uploaded/files/:name', function(req, res) {\n uploader.delete(req, res, function (err,obj) {\n res.Json({error:err}); \n });\n \n });\n return router;\n}\n```\n### SSL Support\n\nSet the `useSSL` option to `true` to use the package with an [HTTPS server](http://expressjs.com/4x/api.html#app.listen).\n```js\nvar express = require('express')\nvar fs = require('fs')\nvar https = require('https');\n\nvar app = express()\n\n// config the uploader\nvar options = {\n ...\n useSSL: true\n ...\n};\n\n// init the uploader\nvar uploader = require('blueimp-file-upload-expressjs')(options);\n\napp.get('/upload', function(req, res) {\n uploader.get(req, res, function (err,obj) {\n if(!err)\n res.send(JSON.stringify(obj)); \n})\n .post('/upload', // ...\n .delete('/uploaded/files/:name', // ...\n\n// create the HTTPS server\nvar app_key = fs.readFileSync('key.pem');\nvar app_cert = fs.readFileSync('cert.pem');\n\nhttps.createServer({key: app_key, cert: app_cert}, app).listen(443);\n\n```\n\n### Multiple thumbnails\n\nTo generate multiple thumbnails while uploading\n\n```js\nvar options = {\n tmpDir: __dirname + '/../public/uploaded/tmp',\n uploadDir: __dirname + '/../public/uploaded/files',\n uploadUrl: '/uploaded/files/',\n copyImgAsThumb: true, // required\n imageVersions: {\n maxWidth: 200,\n maxHeight: 200\n },\n storage: {\n type: 'local'\n }\n};\n```\n`copyImgAsThumb` needs to be set to true. `imageVersions`, `maxWidth` and `maxHeight` will by default create a `thumbnail` folder and place the specified width/height thumbnail in it.\n \nOptionally, you can omit the `maxHeight`. In this case, it will be resize proportionally to the specified width. \n\n```js\nimageVersions: {\n maxWidth: 200\n },\n```\n\nalso\n\n```js\nimageVersions: {\n maxWidth: 200,\n maxHeight : 'auto'\n },\n```\nPS : `auto` value works only with height.\n\nYou can also specify multiple thumbnail generations like \n\n```js\nvar options = {\n tmpDir: __dirname + '/../public/uploaded/tmp',\n uploadDir: __dirname + '/../public/uploaded/files',\n uploadUrl: '/uploaded/files/',\n copyImgAsThumb: true,\n imageVersions: {\n maxWidth: 200,\n maxHeight: 'auto',\n \"large\" : {\n width : 600,\n height : 600\n },\n \"medium\" : {\n width : 300,\n height : 300\n },\n \"small\" : {\n width : 150,\n height : 150\n }\n },\n storage: {\n type: 'local'\n }\n};\n```\n\n## Contributions\n\nChanges and improvements are welcome! Feel free to fork and open a pull request.\n\n### To Do\n* Make [Configuration](#Configuration) documentation clearer and shorter,\n* Refactor code to build tests and provide generic transports as in `winston`, \n* Write end to end tests with [WebdriverIO](http://webdriver.io/),\n* Provide a basic image processing pipeline (resizing, croping, filter effects),\n* Provide access to other cloud-based services like *Microsoft Azure*.\n\n### Done\n\n* ~~Fix Thumbnail creation when uploading images with a more 'feasible' approach~~,\n* ~~Amazon S3 integration~~,\n* ~~SSL Support~~.\n\n***\n## License\n\n*blueimp-file-upload-expressjs* is licensed under the [MIT licence](http://opensource.org/licenses/MIT).\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n",
"readmeFilename": "README.md",
"_id": "[email protected]",
"_shasum": "7f70770aad4683883dcf170c744a89cd7809aa47",
"_from": "../../../../../../../var/folders/n0/znrvzzk10tbd6hy4cdvnpj5h0000gn/T/npm-1132-d71a7db7/1426387788006-0.8811725666746497/eb370db8c5c79475a56d25972dc33e2172b0a4ef",
"_resolved": "git+https://github.com/mamboer/blueimp-file-upload-expressjs#eb370db8c5c79475a56d25972dc33e2172b0a4ef"
}