0

我正在尝试上传大小在 20-100MB 之间的文件,但它们总是无法在 30 秒内上传。这是配置超时的地方,contentful-sdk-core/dist/es-modules/create-http-client.js:

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

我可以覆盖这些设置以允许更慷慨的超时吗?

编辑:我尝试直接在配置选项中更改它们,并且它有效,但我认为这不是一种可持续的做事方式。

4

1 回答 1

0

我在这里得到了 Contentful 的回答:

https://www.contentfulcommunity.com/t/large-file-upload-timeout/607/4

基本上,只需在创建空间时添加超时,如下所示:

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
})
于 2018-01-29T02:40:32.057 回答