0017-00000804错误

问题描述

使用S3 SDK进行分片上传时,Content-Encoding设置为aws-chunked但与x-amz-content-sha256值不兼容。

问题原因

在使用S3 SDK进行分片上传时,请求头中同时满足以下条件将触发此错误:

  • Content-Encoding设置为aws-chunked编码方式

  • x-amz-content-sha256的值与aws-chunked编码不兼容

OSS在处理aws-chunked编码的请求时,要求x-amz-content-sha256参数必须配置为特定值(如STREAMING-AWS4-HMAC-SHA256-PAYLOAD)。如果使用了不支持的x-amz-content-sha256值,系统将拒绝该请求。

问题示例

以下请求中Content-Encoding设置为aws-chunked,但x-amz-content-sha256使用了不兼容的值:

PUT /example-object HTTP/1.1
Host: example-bucket.oss-cn-hangzhou.aliyuncs.com
Content-Encoding: aws-chunked
x-amz-content-sha256: UNSIGNED-PAYLOAD
x-amz-date: 20240320T103000Z
Transfer-Encoding: chunked
Authorization: AWS4-HMAC-SHA256 Credential=...

[Chunked Body]

返回的错误信息如下:

HTTP/1.1 400 Bad Request
Server: AliyunOSS
Date: Mon, 20 Mar 2024 10:30:00 GMT
Content-Type: application/xml
Content-Length: 534
x-oss-request-id: 68******************20
x-oss-ec: 0017-00000804

<?xml version="1.0" encoding="UTF-8"?>
<Error>
  <Code>InvalidArgument</Code>
  <Message>aws-chunked encoding is not supported with the specified x-amz-content-sha256 value.</Message>
  <RequestId>68******************20</RequestId>
  <HostId>example-bucket.oss-cn-hangzhou.aliyuncs.com</HostId>
  <ArgumentName>Content-Encoding</ArgumentName>
  <ArgumentValue>aws-chunked</ArgumentValue>
  <EC>0017-00000804</EC>
  <RecommendDoc>https://api.aliyun.com/troubleshoot?q=0017-00000804</RecommendDoc>
</Error>

解决方案

  • 如果使用aws-chunked编码,需要将x-amz-content-sha256设置为STREAMING-AWS4-HMAC-SHA256-PAYLOAD。

  • 如果不需要使用aws-chunked编码,移除Content-Encoding请求头或设置为其他值。

  • 建议使用OSS标准的分片上传方式(Multipart Upload),而不是依赖S3 SDKaws-chunked编码特性。

  • 确保使用的S3 SDK版本支持OSSaws-chunked编码实现,必要时更新到最新版本。

相关文档