diff --git a/index.js b/index.js index d1f69d8..8b3da53 100644 --- a/index.js +++ b/index.js @@ -37,6 +37,7 @@ function uploadService(opts) { var tmpFiles = []; var files = []; var map = {}; + var fields = {}; var redirect; this.config.host = req.headers.host; @@ -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; } diff --git a/lib/fileinfo.js b/lib/fileinfo.js index 3be09fd..2b76ca0 100644 --- a/lib/fileinfo.js +++ b/lib/fileinfo.js @@ -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; @@ -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(); }