diff --git a/app/middlewares/body-parser.js b/app/middlewares/body-parser.js index dd704d0e..6c44e295 100644 --- a/app/middlewares/body-parser.js +++ b/app/middlewares/body-parser.js @@ -11,7 +11,7 @@ */ var qs = require('qs'); -const Busboy = require('busboy'); +var multer = require('multer'); /** * Extract the mime type from the given request's @@ -141,26 +141,5 @@ exports.parse['application/json'] = function(req, options, fn){ }); }; - -exports.parse['multipart/form-data'] = function(req, options, fn){ - if (req.method === 'POST') { - req.setEncoding('utf8'); - - const busboy = new Busboy({ - headers: req.headers, - limits: { - files: 0 - } - }); - - busboy.on('field', function(fieldname, val) { - req.body[fieldname] = val; - }); - - busboy.on('finish', function() { - fn(); - }); - - req.pipe(busboy); - } -}; +var multipartMiddleware = multer({ limits: { fieldSize: Infinity } }); +exports.parse['multipart/form-data'] = multipartMiddleware.none(); diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 4386c33d..5e91e28a 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -17,6 +17,11 @@ "from": "ansi-styles@>=2.2.1 <3.0.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz" }, + "append-field": { + "version": "0.1.0", + "from": "append-field@>=0.1.0 <0.2.0", + "resolved": "https://registry.npmjs.org/append-field/-/append-field-0.1.0.tgz" + }, "array-flatten": { "version": "1.1.1", "from": "array-flatten@1.1.1", @@ -110,6 +115,11 @@ "from": "brace-expansion@>=1.1.7 <2.0.0", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz" }, + "buffer-from": { + "version": "1.0.0", + "from": "buffer-from@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.0.0.tgz" + }, "buffer-writer": { "version": "1.0.1", "from": "buffer-writer@1.0.1", @@ -185,6 +195,33 @@ "from": "concat-map@0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" }, + "concat-stream": { + "version": "1.6.2", + "from": "concat-stream@>=1.5.0 <2.0.0", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "dependencies": { + "isarray": { + "version": "1.0.0", + "from": "isarray@>=1.0.0 <1.1.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz" + }, + "process-nextick-args": { + "version": "2.0.0", + "from": "process-nextick-args@>=2.0.0 <2.1.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz" + }, + "readable-stream": { + "version": "2.3.6", + "from": "readable-stream@>=2.2.2 <3.0.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz" + }, + "string_decoder": { + "version": "1.1.1", + "from": "string_decoder@>=1.1.1 <1.2.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz" + } + } + }, "content-disposition": { "version": "0.5.1", "from": "content-disposition@0.5.1", @@ -645,6 +682,18 @@ "from": "ms@0.7.1", "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz" }, + "multer": { + "version": "1.2.1", + "from": "multer@>=1.2.0 <1.3.0", + "resolved": "https://registry.npmjs.org/multer/-/multer-1.2.1.tgz", + "dependencies": { + "object-assign": { + "version": "3.0.0", + "from": "object-assign@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-3.0.0.tgz" + } + } + }, "mv": { "version": "2.1.1", "from": "mv@>=2.0.0 <3.0.0", @@ -1093,6 +1142,11 @@ "from": "type-is@>=1.6.6 <1.7.0", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz" }, + "typedarray": { + "version": "0.0.6", + "from": "typedarray@>=0.0.6 <0.0.7", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz" + }, "underscore": { "version": "1.6.0", "from": "underscore@>=1.6.0 <1.7.0", diff --git a/package.json b/package.json index 90559328..f6947749 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,6 @@ "basic-auth": "^2.0.0", "bintrees": "1.0.1", "bunyan": "1.8.1", - "busboy": "^0.2.14", "cartodb-psql": "0.10.1", "cartodb-query-tables": "0.2.0", "cartodb-redis": "1.0.0", @@ -28,6 +27,7 @@ "express": "~4.13.3", "log4js": "cartodb/log4js-node#cdb", "lru-cache": "~2.5.0", + "multer": "~1.2.0", "node-statsd": "~0.0.7", "node-uuid": "^1.4.7", "oauth-client": "0.3.0",