如何解决将数据从 Amazon S3 导入到 DynamoDB 时出现的错误“Unexpected token.Remainder of the file will not be processed.”(意外令牌。文件的其余部分将不被处理。)?

1 分钟阅读
0

当我将数据从 Amazon Simple Storage Service (Amazon S3) 导入到 Amazon DynamoDB 时,导入失败并出现以下错误: “Unexpected token.Remainder of the file will not be processed.”(意外令牌。文件的其余部分将不被处理。)

解决方法

要解决此错误,请查看 Amazon S3 对象的数据格式、压缩类型和路径。您的 Amazon S3 存储桶中的数据必须采用 CSV、DynamoDB JSON 或 ION 格式。只能使用 GZIP 或 ZSTD 压缩数据。不能使用其他类型的压缩,也不能对数据进行压缩。

要查看此信息,请完成以下步骤:

  1. 打开 DynamoDB 控制台

  2. 在导航窗格中,选择 Imports from S3(从 S3 导入)。

  3. Import options(导入选项)页面上,输入 .../data 文件夹的源 S3 URL。例如,使用以下格式指定导入 ARN:
    s3://my-bucket/AWSDynamoDB/<hyphen_separated_foldername>/data/

  4. 输入以下信息:
    对于 Import file format(导入文件格式),选择 CSVDynamoDB JSONION
    对于 Import file compression(导入文件压缩),请选择 GZIPZSTDNone(无)。
    **注意:**如果 S3 源存储桶类型为 gz,请选择 GZIP
    以下示例的文件类型为 gz

    {
     "itemS3Pointer": {
     "bucket": "test",
     "key": "AWSDynamoDB/01714549541xxxx-1ab21b72/data/am2dghk2om7epke3wrnn3sgz24.json.gz"
     },
     "importArn": "arn:aws:dynamodb:eu-west-1:79205873xxxx:table/new1/import/01714550075760-3658717a",
     "errorMessages": [
     "Unexpected token. Remainder of the file will not be processed."
     ]
    }
  5. 选择 Next(下一步)。

  6. 输入目标表的详细信息。

  7. 选择 Import(导入)。

导入需要几分钟。您可以在 Imports from S3(从 S3 导入)页面上跟踪您的导入状态。

AWS 官方
AWS 官方已更新 8 个月前