rayen
rayen

Reputation: 380

Large file upload in strapi fails

Using strapi 3.0.0-alpha.14.1.1, upload-local file provider and mongodb, it fails to upload a 500 MB file. Though the "Maximum size allowed (in MB)" is set to 10000 MB, it throws the following error:

Using curl:

curl -X POST -F 'files=@/development/TestFiles/largefile.zip' http://localhost:1337/upload

{"message":"An internal server error occurred","statusCode":500,"error":"Internal Server Error"}

Using admin panel:

Error: maxFileSize exceeded, received 209780558 bytes of file data
at Stream.<anonymous> (/usr/lib/node_modules/strapi/node_modules/formidable/lib/incoming_form.js:222:19)
at emitOne (events.js:116:13)
at Stream.emit (events.js:211:7)
at MultipartParser.parser.onPartData (/usr/lib/node_modules/strapi/node_modules/formidable/lib/incoming_form.js:387:14)
at callback (/usr/lib/node_modules/strapi/node_modules/formidable/lib/multipart_parser.js:102:31)
at dataCallback (/usr/lib/node_modules/strapi/node_modules/formidable/lib/multipart_parser.js:112:11)
at MultipartParser.write (/usr/lib/node_modules/strapi/node_modules/formidable/lib/multipart_parser.js:305:3)
at IncomingForm.write (/usr/lib/node_modules/strapi/node_modules/formidable/lib/incoming_form.js:159:34)
at IncomingMessage.<anonymous> (/usr/lib/node_modules/strapi/node_modules/formidable/lib/incoming_form.js:125:12)
at emitOne (events.js:116:13)
at IncomingMessage.emit (events.js:211:7)
at IncomingMessage.Readable.read (_stream_readable.js:475:10)
at flow (_stream_readable.js:846:34)
at resume_ (_stream_readable.js:828:3)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickDomainCallback (internal/process/next_tick.js:218:9)

Any help please?

Upvotes: 0

Views: 3266

Answers (1)

rayen
rayen

Reputation: 380

Thanks to Flux159(in github)

Created an issue in github and got the below working repsonse. Might be useful for others:

In config/environments/development/request.json, you need to change the koa body parser config for formidable:

Example: Setting maxFileSize to 500MB for formidable (number is in bytes so 500*1024*1024):

...
"parser": {
    "enabled": true,
    "multipart": true,
    "formidable": {
      "maxFileSize": 524288000
    }
  },
...

For further details refer: https://github.com/strapi/strapi/issues/1975#issuecomment-423839266

Upvotes: 3

Related Questions