内容丰富-资产未处理

时间:2020-11-12 05:53:09

标签: node.js contentful contentful-management contentful-api

我正在尝试将资产从一个环境迁移到同一空间中的另一个环境。

我正在使用createAssetWithId中的Contentful Management API方法将资产及其ID从source环境迁移到target环境。

但是,发布时出现此错误:

ValidationFailed: {
  "status": 422,
  "statusText": "Unprocessable Entity",
  "message": "Validation error",
  "details": {
    "errors": [
      {
        "name": "badFileUrl",
        "path": [
          "fields",
          "file",
          "en-US",
          "url"
        ],
        "details": "Invalid asset URL"
      }
    ]
  },
  "request": {
    "url": "assets/5KRzAvo7a4xq7iuLuuQ9B3/published",
    "headers": {
      "Accept": "application/json, text/plain, */*",
      "Content-Type": "application/vnd.contentful.management.v1+json",
      "X-Contentful-User-Agent": "sdk contentful-management.js/5.28.0; platform node.js/v10.16.2; os Windows/10.0.18362;",
      "Authorization": "Bearer ...fbbFQ",
      "user-agent": "node.js/v10.16.2",
      "Accept-Encoding": "gzip",
      "X-Contentful-Version": 2
    },
    "method": "put",
    "payloadData": null
  },
  "requestId": "f77f2c74115b8bf071fd58455f26bd27"
}

这是creatingprocessing资产的代码。之后是发布部分。

await cmaClient.getSpace(spaceId)
        .then(async (space) => await space.getEnvironment(environmentId))
        .then(async (environment) => await environment.createAssetWithId(assetItem.sys.id, { fields: assetItem.fields }))
        .then(async (asset) => await asset.processForAllLocales({ processingCheckWait: 5000, processingCheckRetries: 25 }))
        .then(customLogger.success(`Asset '${assetItem.sys.id}' has been created.`))
        .catch(customLogger.error)

assetItem.fields具有以下属性:

{ title: { 'en-US': 'image title' },
  description: { 'en-US': ' ' },
  file:
   { 'en-US':
      { fileName: '',
        contentType: 'image/jpeg',
        upload:
         'https://images.ctfassets.net/<space_id>/<asset_id>/2hj84bce4dedcfc78654b98hhhr452t7/image.jpg' } } }

资产已创建,但图像未显示,未处理且因此未发布。

0 个答案:

没有答案