From 70ed499110483f8670262d6a4b128944964ee5d4 Mon Sep 17 00:00:00 2001 From: Dudemullet Date: Tue, 14 Oct 2014 09:34:01 -0500 Subject: [PATCH 1/2] Adds 'force' option to overwrite files with same name --- index.js | 3 ++- lib/uploadhandler.js | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 0ebaf48..00bcdbe 100644 --- a/index.js +++ b/index.js @@ -28,7 +28,8 @@ JqueryFileUploadMiddleware.prototype.prepareOptions = function (options) { accessControl: { allowOrigin: '*', allowMethods: 'OPTIONS, HEAD, GET, POST, PUT, DELETE' - } + }, + force: false //Overwrite file with same name }, options); _.each(['uploadDir', 'uploadUrl'], function (key) { diff --git a/lib/uploadhandler.js b/lib/uploadhandler.js index 070f018..d419a35 100644 --- a/lib/uploadhandler.js +++ b/lib/uploadhandler.js @@ -92,7 +92,9 @@ module.exports = function (options) { .on('fileBegin', function (name, file) { tmpFiles.push(file.path); var fileInfo = new FileInfo(file); - fileInfo.safeName(); + if(!options.force) { + fileInfo.safeName(); + } map[path.basename(file.path)] = fileInfo; files.push(fileInfo); self.emit('begin', fileInfo); From b7b43690b54c4b50b63ece451c04eea895c84a6d Mon Sep 17 00:00:00 2001 From: Dudemullet Date: Wed, 15 Oct 2014 07:44:24 -0500 Subject: [PATCH 2/2] Added flag reference to README --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 204c7a3..a16b2cd 100644 --- a/README.md +++ b/README.md @@ -270,7 +270,8 @@ Other options and their default values: accessControl: { allowOrigin: '*', allowMethods: 'OPTIONS, HEAD, GET, POST, PUT, DELETE' - } + }, + force: false // Overwrite files with the same name on upload } ```