可以覆盖 js 管理 SDK 上传的超时



我正在尝试上传大小在 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);

是否可以覆盖这些设置以允许更宽泛的超时?

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

我在这里得到了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
})

最新更新