strapi 中的大文件上传失败
Large file upload in strapi fails
使用 strapi 3.0.0-alpha.14.1.1、上传本地文件提供程序和 mongodb,无法上传 500 MB 的文件。虽然 "Maximum size allowed (in MB)" 设置为 10000 MB,但它会引发以下错误:
使用卷曲:
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"}
使用管理面板:
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)
有什么帮助吗?
感谢 Flux159(在 github 中)
在 github 中创建了一个问题并获得了以下工作响应。可能对其他人有用:
在 config/environments/development/request.json 中,您需要将 koa 主体解析器配置更改为 formidable:
示例:将 maxFileSize 设置为 500MB 以实现强大(数字以字节为单位,因此 500*1024*1024):
...
"parser": {
"enabled": true,
"multipart": true,
"formidable": {
"maxFileSize": 524288000
}
},
...
更多详情请参考:https://github.com/strapi/strapi/issues/1975#issuecomment-423839266
使用 strapi 3.0.0-alpha.14.1.1、上传本地文件提供程序和 mongodb,无法上传 500 MB 的文件。虽然 "Maximum size allowed (in MB)" 设置为 10000 MB,但它会引发以下错误:
使用卷曲:
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"}
使用管理面板:
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)
有什么帮助吗?
感谢 Flux159(在 github 中)
在 github 中创建了一个问题并获得了以下工作响应。可能对其他人有用:
在 config/environments/development/request.json 中,您需要将 koa 主体解析器配置更改为 formidable:
示例:将 maxFileSize 设置为 500MB 以实现强大(数字以字节为单位,因此 500*1024*1024):
...
"parser": {
"enabled": true,
"multipart": true,
"formidable": {
"maxFileSize": 524288000
}
},
...
更多详情请参考:https://github.com/strapi/strapi/issues/1975#issuecomment-423839266