Strapi with Cloudinary - upload large files issue

System Information
  • Strapi Version: 4.3.6
  • Operating System: Windows 11
  • Database: sqlite on development mode and postgres on production
  • Node Version: 16.14.0
  • NPM Version: 8.3.1
  • Yarn Version: 1.22.15

Hey everyone :slight_smile:
I had an issue with uploading larger audio files using cloudinary provider in Strapi 4.
When file was uploded to the end, I waited small amount of time and received red screen inside uploader with X and error:

On Strapi admin panel inside console, I received status 500:

I had also error like this: Error uploading to cloudinary: Server returned unexpected status code - 413 - basically this error appears in logs on web server on render.com.

Sometimes web server has status server failed and there is status info about that failure:
image

this is my middleware.js config and plugins.js config in development mode and also in env/production file for production mode:

    name: 'strapi::security',
    config: {
      contentSecurityPolicy: {
        useDefaults: true,
        directives: {
          'connect-src': ["'self'", 'https:'],
          'img-src': ["'self'", 'data:', 'blob:', 'dl.airtable.com', 'res.cloudinary.com'],
          'media-src': ["'self'", 'data:', 'blob:', 'dl.airtable.com', 'res.cloudinary.com'],
          upgradeInsecureRequests: null,
        },
      },
    },
  },

And plugins config:

    upload: {
        config: {
            provider: 'cloudinary',
            providerOptions: {
                cloud_name: env('CLOUDINARY_NAME'),
                api_key: env('CLOUDINARY_KEY'),
                api_secret: env('CLOUDINARY_SECRET'),
            },
            actionOptions: {
                upload: {},
                uploadStream: {},
                delete: {},
            },
        },
    }

One of the thing I’ve searched is that Cloudinary block uploading files greater than 100mb except of providing some configuration (see here: Programmatically Uploading Images, Videos, and Other Files | Cloudinary)
This is from the issue post from this source: https://support.cloudinary.com/hc/en-us/community/posts/360008228219-getting-Server-returned-unexpected-status-code-413-when-uploading-150MB-video
the fact is that I uploaded files with about 90mb ant it was fine, but above 100mb it couldn’t handle, so it is probably the case.

I also received a link to Strapi middleware configurations from someone, but I am trying to understand it yest to be honest.
https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/required/middlewares.html#internal-middlewares-configuration-reference

I also want to mention that on development mode it also doesn’t work, so maybe it is a problem with cloudinary config settings to set it properly. Maybe it has some default restrictions for larger files, i don’t know. I hope someone could know where is the problem.

Appreciate anyones help :slight_smile:

Did you find a solution to this? Are you on Heroku? We increased our Cloudinary limit so over 100Mb is OK now with Cloudinary, but Strapi still has an issue uploading, because Heroku apparently crashes the app when it gets over 100Mb. I read Heroku have a strict 30 second timeout limit and this may be the reason for us as opposed to the file size. Not sure how to get around this.

We cant upliad direct to Cloudinary because Strapi does not show the folders in Cloudinary. Cloudinary does not show the folders in Strapi! So because we’re adding media to entries in Strapi we chose to use Strapi to manage media folders, but it means we can’t upload direct to Cloudinary because they are not Cloudinary folders, they are Strapi folders.

1 Like

Regarding the first issue mentioned by @konat1993 , in case anyone have it: we had a similar problem and the solution was: to increase the RAM memory of the instance running Strapi. Additionally, if the file is larger than 100MB, you must ensure that your Cloudinary plan supports uploading larger files (More information here https://support.cloudinary.com/hc/en-us/articles/202520592-Do-you-have-a-file-size-limit#:~:text=Please%20note%20that%20uploads%20of,files%20without%20using%20chunked%20uploads.).

On the other hand, for the issue raised by @lozcozard , we still currently have the same difficulty with Strapi 4.20.0 running in Heroky. We encounter a timeout error when uploading “large” files (150MB approx), which is caused by the maximum time supported by Heroku during the upload process. Has anyone found a way to solve or workaround this?