From 21cc8ed87a6c3d61dd3fa9498a77ace7efc5d992 Mon Sep 17 00:00:00 2001 From: jan876 Date: Sat, 18 Apr 2015 02:48:38 -0700 Subject: [PATCH 1/4] Exposing upload handler. Upload handler can be used directly and post validation/control can be added. --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 0ebaf48..99c59c7 100644 --- a/index.js +++ b/index.js @@ -55,4 +55,8 @@ JqueryFileUploadMiddleware.prototype.fileManager = function (options) { return require('./lib/filemanager')(this, this.prepareOptions(_.extend(this.options, options))); }; -module.exports = new JqueryFileUploadMiddleware(); \ No newline at end of file +JqueryFileUploadMiddleware.prototype.uploadHandler = function (options, callback) { + return require('./lib/uploadhandler')(this, this.prepareOptions(_.extend(this.options, options)), callback); +}; + +module.exports = new JqueryFileUploadMiddleware(); From 19d9f6dd022102308b370f3226c8d3b8114af08f Mon Sep 17 00:00:00 2001 From: jan876 Date: Sat, 18 Apr 2015 03:01:18 -0700 Subject: [PATCH 2/4] Removed callback from newly exposed uploadHandler Removed the callback which can be added later from uploadHandler. --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 99c59c7..e8ca38e 100644 --- a/index.js +++ b/index.js @@ -55,8 +55,8 @@ JqueryFileUploadMiddleware.prototype.fileManager = function (options) { return require('./lib/filemanager')(this, this.prepareOptions(_.extend(this.options, options))); }; -JqueryFileUploadMiddleware.prototype.uploadHandler = function (options, callback) { - return require('./lib/uploadhandler')(this, this.prepareOptions(_.extend(this.options, options)), callback); +JqueryFileUploadMiddleware.prototype.uploadHandler = function (options) { + return require('./lib/uploadhandler')(this, this.prepareOptions(_.extend(this.options, options))); }; module.exports = new JqueryFileUploadMiddleware(); From 551514fbf971501ab9dfbf8b6081fdf9a69f4f21 Mon Sep 17 00:00:00 2001 From: jan876 Date: Sat, 18 Apr 2015 22:32:54 -0700 Subject: [PATCH 3/4] Added middleware option. --- lib/uploadhandler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/uploadhandler.js b/lib/uploadhandler.js index 070f018..f64ef96 100644 --- a/lib/uploadhandler.js +++ b/lib/uploadhandler.js @@ -7,7 +7,7 @@ var EventEmitter = require('events').EventEmitter, _ = require('lodash'), async = require('async'); -module.exports = function (options) { +module.exports = function (middleware, options) { var FileInfo = require('./fileinfo')( _.extend({ From d39333412517aee957299c1770cfae4a6bd263b0 Mon Sep 17 00:00:00 2001 From: jan876 Date: Sat, 18 Apr 2015 22:33:24 -0700 Subject: [PATCH 4/4] Fixed filehandler --- lib/filehandler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/filehandler.js b/lib/filehandler.js index 3b6b625..0395069 100644 --- a/lib/filehandler.js +++ b/lib/filehandler.js @@ -5,7 +5,7 @@ module.exports = function (middleware, options) { 'Access-Control-Allow-Origin': options.accessControl.allowOrigin, 'Access-Control-Allow-Methods': options.accessControl.allowMethods }); - var UploadHandler = require('./uploadhandler')(options); + var UploadHandler = require('./uploadhandler')(middleware, options); var handler = new UploadHandler(req, res, function (result, redirect) { if (redirect) { files = {files: result};