Skip to content

Commit 4ed5aaa

Browse files
committed
Newest version of formidable changes the default maximum file size to 2MB, which is way too low for anything. Make the limit configurable and set to 1GB by default.
1 parent e9d03ae commit 4ed5aaa

4 files changed

Lines changed: 20 additions & 2 deletions

File tree

lib/cli/storage-s3/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ module.exports.builder = function(yargs) {
1616
, type: 'string'
1717
, demand: true
1818
})
19+
.option('max-file-size', {
20+
describe: 'Maximum file size to allow for uploads. Note that nginx ' +
21+
'may have a separate limit, meaning you should change both.'
22+
, type: 'number'
23+
, default: 1 * 1024 * 1024 * 1024
24+
})
1925
.option('port', {
2026
alias: 'p'
2127
, describe: 'The port to bind to.'
@@ -39,5 +45,6 @@ module.exports.handler = function(argv) {
3945
, profile: argv.profile
4046
, bucket: argv.bucket
4147
, endpoint: argv.endpoint
48+
, maxFileSize: argv.maxFileSize
4249
})
4350
}

lib/cli/storage-temp/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ module.exports.builder = function(yargs) {
88
return yargs
99
.env('STF_STORAGE_TEMP')
1010
.strict()
11+
.option('max-file-size', {
12+
describe: 'Maximum file size to allow for uploads. Note that nginx ' +
13+
'may have a separate limit, meaning you should change both.'
14+
, type: 'number'
15+
, default: 1 * 1024 * 1024 * 1024
16+
})
1117
.option('port', {
1218
alias: 'p'
1319
, describe: 'The port to bind to.'
@@ -29,5 +35,6 @@ module.exports.handler = function(argv) {
2935
return require('../../units/storage/temp')({
3036
port: argv.port
3137
, saveDir: argv.saveDir
38+
, maxFileSize: argv.maxFileSize
3239
})
3340
}

lib/units/storage/s3.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ module.exports = function(options) {
7272
}
7373

7474
app.post('/s/upload/:plugin', function(req, res) {
75-
var form = new formidable.IncomingForm()
75+
var form = new formidable.IncomingForm({
76+
maxFileSize: options.maxFileSize
77+
})
7678
var plugin = req.params.plugin
7779
Promise.promisify(form.parse, form)(req)
7880
.spread(function(fields, files) {

lib/units/storage/temp.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ module.exports = function(options) {
8383
})
8484

8585
app.post('/s/upload/:plugin', function(req, res) {
86-
var form = new formidable.IncomingForm()
86+
var form = new formidable.IncomingForm({
87+
maxFileSize: options.maxFileSize
88+
})
8789
if (options.saveDir) {
8890
form.uploadDir = options.saveDir
8991
}

0 commit comments

Comments
 (0)