Upload Very Large Files

System Information
  • 3.6.8:
  • Docker strapi image (linux):
  • Postgres:
  • 12.20.1:
  • 6.14.10:

I can’t upload files roughly over 2GB. Error file to large 413
Filesize limits in config/middlerware.js and extensions/upload/config.json are set to 100GB.

Error (log level on debug):

method: 'select',
options: {},
timeout: false,
cancelOnTimeout: false,
bindings: [ 3, 'upload', 'upload', 'upload', true, 1 ],
__knexQueryUid: '04868608-5667-499e-8476-f794db231fbf',
sql: 'select "users-permissions_permission".* from "users-permissions_permission" left join "strapi"."public"."users-permissions_role" as "users-permissions_role_1" on "users-permissions_role_1"."id" = "users-permissions_permission"."role" where "users-permissions_role_1"."id" = ? and "users-permissions_permission"."type" = ? and "users-permissions_permission"."controller" = ? and "users-permissions_permission"."action" = ? and "users-permissions_permission"."enabled" = ? limit ?'
 }
[2022-02-09T08:00:49.008Z] debug POST /upload (3387 ms) 413

There is no nginx in between. I post the file directly from / to the localhost.

Upload config (app/extensions/upload/config/config.json):

{
  "enabled": true,
  "provider": "local",
  "providerOptions": {
    "sizeLimit": 858993459200
  },
  "actionOptions": {}
}

Middleware.js /app/config/middleware.js:

module.exports = {
  settings: {
    parser: {
      enabled: true,
      multipart: true,
      formLimit: '100gb', 
      jsonLimit: '100gb',
      formidable: {
        maxFileSize: 858993459200
      }
    }
  },
};

If anybody could give me any advice where this problem could originate from. Would help me very much.
Thank you

Hi @Marcel_Colomb ! Do you found a work around for this issue?

1 Like

Hi @Marcel_Colomb ! Do you found a work around for this issue? my Problem are 4GB files

1 Like

For anyone stumbling upon this. We had the problem that after 330 seconds the download stopped automatically because of a timeout. We searched for ages… this was the solution: in src/index.ts (or src/index.js), in the bootstrap function, set the strapi.server.httpServer.requestTimeout to a higher value:

bootstrap({ strapi }) {
    strapi.server.httpServer.requestTimeout = 30 * 60 * 1000; 
  },

Here’s a solution that addresses this issue. The problem is that every file uploaded is checked with sharp to determine if it’s an image or not. Sharp uses Node buffers which have a 2GB limit, so the solution is simply to modify this function so that if the file is larger than 2GB, it skips this process and everything works. Link to the code with the solution is attached.