diff --git a/lib/plugins/multipartBodyParser.js b/lib/plugins/multipartBodyParser.js index c94a90776..cf077d436 100644 --- a/lib/plugins/multipartBodyParser.js +++ b/lib/plugins/multipartBodyParser.js @@ -116,6 +116,30 @@ function multipartBodyParser(options) { if (req.params[f] && !override) { return; } + if (Array.isArray(files[f])) { + req.params[f] = []; + files[f].forEach(function forEach2(file) { + barrier.start('fs' + file.name); + fs.readFile(file.path, function readFile( + ex, + data + ) { + barrier.done('fs' + file.name); + if (ex) { + return next( + new errors.InternalError( + ex, + 'unable to read file' + + file.name + ) + ); + } + req.params[f].push(data); + return true; + }); + }); + } + barrier.start('fs' + f); fs.readFile(files[f].path, function readFile(ex, data) { barrier.done('fs' + f); diff --git a/test/plugins/multipart.test.js b/test/plugins/multipart.test.js index 257d2ce0f..33588cade 100644 --- a/test/plugins/multipart.test.js +++ b/test/plugins/multipart.test.js @@ -204,6 +204,14 @@ describe('multipart parser', function() { client.write(echoes + '\r\n'); client.write('--huff--'); + client.write( + 'Content-Disposition: form-data; name="echoes"; ' + + 'filename="echoes2.txt"\r\n' + ); + client.write('Content-Type: text/plain\r\n\r\n'); + client.write(echoes + '\r\n'); + client.write('--huff--'); + client.end(); });