express-form-post
Advanced tools
Comparing version 1.0.25 to 1.0.26
@@ -1,20 +0,27 @@ | ||
const concat = require("concat-stream"); | ||
const Stream = require("stream"); | ||
const path = require("path"); | ||
const db = require("dropbox-stream"); | ||
module.exports = function(uploadInfo, req, finished, handleError) { | ||
let save_path = path.join(uploadInfo.directory, uploadInfo.filename); | ||
save_path[0] != "/" ? save_path = "/" + save_path : ""; // dropbox requires absolute path | ||
return concat((data) => { | ||
uploadInfo.apiObject.filesUpload({ | ||
path: save_path, | ||
contents: data | ||
}) | ||
.then(function(response) { | ||
req.files[uploadInfo.fieldname] = response; | ||
finished(); | ||
}) | ||
.catch(function(error) { | ||
handleError(new Error(error.error)); | ||
}); | ||
save_path[0] != "/" ? save_path = "/" + save_path : ""; // dropbox requires absolute path | ||
const pass = new Stream.PassThrough(); | ||
let up = db.createDropboxUploadStream({ | ||
token: this.apiObject.accessToken, | ||
filepath: save_path | ||
}) | ||
.on("done", (response) => { | ||
req.files[uploadInfo.fieldname] = response; | ||
finished(); | ||
}) | ||
.on("progress", (response) => {}) | ||
.on("error", (err) => { | ||
handleError(new Error(error.error)); | ||
}); | ||
pass.pipe(up); | ||
return pass; | ||
}; |
{ | ||
"name": "express-form-post", | ||
"version": "1.0.25", | ||
"version": "1.0.26", | ||
"description": "Simple, reliable express http file and post body handler.", | ||
@@ -34,3 +34,2 @@ "main": "index.js", | ||
"busboy": "^0.2.14", | ||
"concat-stream": "^1.6.0", | ||
"hasha": "^3.0.0", | ||
@@ -43,7 +42,9 @@ "mkdirp": "^0.5.1" | ||
"dropbox": "^2.5.4", | ||
"dropbox-stream": "^1.0.5", | ||
"ejs": "^2.5.6", | ||
"eslint": "^3.19.0", | ||
"express": "^4.15.3", | ||
"nodemon": "^1.11.0" | ||
"nodemon": "^1.11.0", | ||
"concat-stream": "^1.6.0" | ||
} | ||
} |
@@ -114,3 +114,3 @@ # Express Form Post [![npm version](https://badge.fury.io/js/express-form-post.svg)](https://badge.fury.io/js/express-form-post) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard) | ||
```sh | ||
$ npm install dropbox --save | ||
$ npm install dropbox-stream --save | ||
``` | ||
@@ -117,0 +117,0 @@ |
29138
3
435
9
- Removedconcat-stream@^1.6.0
- Removedbuffer-from@1.1.2(transitive)
- Removedconcat-stream@1.6.2(transitive)
- Removedisarray@1.0.0(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedtypedarray@0.0.6(transitive)
- Removedutil-deprecate@1.0.2(transitive)