diff --git a/lib/cli/storage-s3/index.js b/lib/cli/storage-s3/index.js index 334a13f0..30723a70 100644 --- a/lib/cli/storage-s3/index.js +++ b/lib/cli/storage-s3/index.js @@ -16,6 +16,12 @@ module.exports.builder = function(yargs) { , type: 'string' , demand: true }) + .option('max-file-size', { + describe: 'Maximum file size to allow for uploads. Note that nginx ' + + 'may have a separate limit, meaning you should change both.' + , type: 'number' + , default: 1 * 1024 * 1024 * 1024 + }) .option('port', { alias: 'p' , describe: 'The port to bind to.' @@ -39,5 +45,6 @@ module.exports.handler = function(argv) { , profile: argv.profile , bucket: argv.bucket , endpoint: argv.endpoint + , maxFileSize: argv.maxFileSize }) } diff --git a/lib/cli/storage-temp/index.js b/lib/cli/storage-temp/index.js index 13d86245..c3be46cc 100644 --- a/lib/cli/storage-temp/index.js +++ b/lib/cli/storage-temp/index.js @@ -8,6 +8,12 @@ module.exports.builder = function(yargs) { return yargs .env('STF_STORAGE_TEMP') .strict() + .option('max-file-size', { + describe: 'Maximum file size to allow for uploads. Note that nginx ' + + 'may have a separate limit, meaning you should change both.' + , type: 'number' + , default: 1 * 1024 * 1024 * 1024 + }) .option('port', { alias: 'p' , describe: 'The port to bind to.' @@ -29,5 +35,6 @@ module.exports.handler = function(argv) { return require('../../units/storage/temp')({ port: argv.port , saveDir: argv.saveDir + , maxFileSize: argv.maxFileSize }) } diff --git a/lib/units/storage/s3.js b/lib/units/storage/s3.js index e44bafff..26c6d53e 100644 --- a/lib/units/storage/s3.js +++ b/lib/units/storage/s3.js @@ -72,7 +72,9 @@ module.exports = function(options) { } app.post('/s/upload/:plugin', function(req, res) { - var form = new formidable.IncomingForm() + var form = new formidable.IncomingForm({ + maxFileSize: options.maxFileSize + }) var plugin = req.params.plugin Promise.promisify(form.parse, form)(req) .spread(function(fields, files) { diff --git a/lib/units/storage/temp.js b/lib/units/storage/temp.js index 89dd33f7..8556725c 100644 --- a/lib/units/storage/temp.js +++ b/lib/units/storage/temp.js @@ -83,7 +83,9 @@ module.exports = function(options) { }) app.post('/s/upload/:plugin', function(req, res) { - var form = new formidable.IncomingForm() + var form = new formidable.IncomingForm({ + maxFileSize: options.maxFileSize + }) if (options.saveDir) { form.uploadDir = options.saveDir }