Search code examples
body-parserstrapi

Strapi Body-Parser File Size Settings


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}));

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! :)


Solution

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

    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
            },
        },