Strapi Body-Parser 文件大小设置 [英] Strapi Body-Parser File Size Settings

查看:35
本文介绍了Strapi Body-Parser 文件大小设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将文件上传到 Strapi API,但我不断收到文件太大的错误消息.我想发送一个 1mb 的文件.通常在 Express/Koa 中,我可以像这样更改 body-parser 设置:

I am trying to upload a file to the Strapi API, but I keep getting an error that my file is too large. I want to send a 1mb file. Usually in Express/Koa I could change the body-parser settings like this:

app.use(bodyParser.json({limit: '50mb'}));
app.use(bodyParser.urlencoded({limit: '50mb', extended: true}));

但由于 Strapi 是一个封闭的系统,我不确定在哪里设置或编辑它.

But since Strapi is such a closed off system, I am not sure where to set or edit this.

非常感谢所有帮助和指示!:)

All help and pointers are greatly appreciated! :)

推荐答案

在 v3.x.x 中,设置现在显然位于 ./config/middleware.js

In v3.x.x the settings are apparently now located in ./config/middleware.js

事实证明,增加文件大小是不够的,您还必须确保 formLimitjsonLimit 也增加了.

And it turns out that increasing the file size was not enough, you also have to make sure the formLimit and jsonLimit are also increased.

    parser: {
        //..
        formLimit: '50mb', <--
        jsonLimit: '50mb', <--
        formidable: {
            maxFileSize: 50 * 1024 * 1024, // 50MB
        },
    },

这篇关于Strapi Body-Parser 文件大小设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆