Skip to content

Commit

Permalink
Merge pull request #42 from abhijeetdhumal/master
Browse files Browse the repository at this point in the history
Modifying code to accept additional form fields along with images
  • Loading branch information
arvindr21 committed May 17, 2015
2 parents e25e711 + c3ada55 commit 3750731
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function uploadService(opts) {
var tmpFiles = [];
var files = [];
var map = {};
var fields = {};
var redirect;

this.config.host = req.headers.host;
Expand Down Expand Up @@ -74,10 +75,11 @@ function uploadService(opts) {
tmpFiles.push(file.path);
// fix #41
configs.saveFile = true;
var fileInfo = new FileInfo(file, configs);
var fileInfo = new FileInfo(file, configs, fields);
map[fileInfo.key] = fileInfo;
files.push(fileInfo);
}).on('field', function(name, value) {
fields[name] = value;
if (name === 'redirect') {
redirect = value;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/fileinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var getFileKey = function(filePath) {
};
var udf;

function FileInfo(file, opts) {
function FileInfo(file, opts, fields) {
this.name = file.name;
this.size = file.size;
this.type = file.type;
Expand All @@ -26,6 +26,7 @@ function FileInfo(file, opts) {
this.proccessed = false;
this.width = udf;
this.height = udf;
this.fields = fields;
if (opts.saveFile) {
this.safeName();
}
Expand Down

0 comments on commit 3750731

Please sign in to comment.