I installed the strapi server on digital ocean and it works nice. But the standard configuration of the media library filesize is set to 1 MB, which is too less.

How can i configure this to - let’s say - 5MB per file (image)

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
2 answers

The answer is not in the strapi configuration, but in the nginx.conf file.

By default, Nginx has a limit of 1MB on file uploads. To set file upload size, you can use the clientmaxbodysize directive, which is part of Nginx’s ngxhttpcoremodule module. This directive can be set in the http, server or location context.

It sets the maximum allowed size of the client request body, specified in the “Content-Length” request header field. Here’s an example of increasing the limit to 100MB in /etc/nginx/nginx.conf file.

http {

clientmaxbody_size 100M;
}

Hello, @bstuijts

You can double check the maxFileSize in the config/environments/development/request.json file

"parser": {
    "enabled": true,
    "multipart": true,
    "formidable": {
      "maxFileSize": 52428800
    }
  }

You can adjust the value according to your needs. You can further check the strapi documentation using the following link:

https://strapi.io/documentation/3.0.0-beta.x/plugins/upload.html

Hope this helps!

Regards,
Alex

  • I did make these changes. And run the npm run build command in the terminal.

    I tried to look up the service loaded with pm2 -status but found none. How do I restart the strapi server after this change? I expect the following to do’s:

    1. Stop the pm2 process
    2. Build new strapi server, with above modifications
    3. Start the pm2 process

    I have the feeling i’m getting close. Please help me out here.

    • This was bugging me for a bit too. It ended up indeed being the nginx.conf file.

      Since this is a server based file outside of the strapi/webpack build, the entire server needs to be rebooted for it to stick.

      My server was on an EC2 instance and I called:

      sudo reboot
      

      to reboot the whole thing after updating that conf file using the nano / vim

      If you set up the server per the strapi instructions to where it will auto start the pm2 instance, then after the reboot is all over, it should be up and running.

      Be sure to use

      pm2 status 
      

      and

      pm2 logs 
      

      To ensure all is running smoothly.
      Hope this helps

Submit an Answer