Large file upload timeout

Pardon if this is is less of a Contentful question and more of a Javascript question, but I’m not sure what the best approach is because I’m doing a lot of this for the first time. I’ve designed a React/Redux app that allows users to upload video files, images, documents. In my part of the world, internet upload speeds are often slow. When file size is above 5MB or so, it will time out.

Is the solution to chunk uploads? Change timeout limit somehow? What is the best way to avoid timing out on slow uploads of larger files. I’d like to be able to handle up to 100MB.

A Google search for ‘JavaScript large file upload’ returns a lot of good results. For example:

1 Like

Thank you Charlie! Like I said, I wasn’t sure if there was something on the Contentful side of things I could do. Obviously it’s more of a Javascript learning issue for me. I appreciate your help! I’ll come back here and post what ultimately works.

In the ‘contentful-sdk-core/dist/es-modules/create-http-client.js’ file, the management sdk creates an instance of axios and configures it to have a 30000 ms time out.

//LINES 30-53 of create-http-client.js
var defaultConfig = {
insecure: false,
retryOnError: true,
logHandler: function logHandler(level, data) {
  if (level === 'error' && data) {
    var title = [, data.message].filter(function (a) {
      return a;
    }).join(' - ');
    console.error('[error] ' + title);
  console.log('[' + level + '] ' + data);
// Passed to axios
headers: {},
httpAgent: false,
httpsAgent: false,
timeout: 30000,
proxy: false,
basePath: ''
var config = _extends({}, defaultConfig, options);

Chunking file uploads is not really necessary for the size of file I’m trying to upload nor do I have any control over what Contentful does with the file chunks on the other end, I assume.

How can I override this timeout?

You can override the timeout by simply adding an option timeout creating the client.

var contentful = require('contentful')
var client = contentful.createClient({
  // This is the space ID. A space is like a project folder in Contentful terms
  space: <space-id>,
  // This is the access token for this space. Normally you get both ID and the token in the Contentful web app
  accessToken: <delivery-token>,
  timeout: 999999
1 Like

I just realized that it is missing from the docs, sorry about that. I will update it soon