问题描述
设置x-oss-user-last-modified请求头时,提供的日期值不合法。
问题原因
在上传或修改对象时,通过x-oss-user-last-modified请求头指定了对象的最后修改时间,但是提供的日期值早于1970-01-01 00:00:00,不符合接口要求。
OSS要求x-oss-user-last-modified的取值必须晚于1970-01-01 00:00:00(UTC时间),这是因为系统内部使用Unix时间戳表示时间,而Unix时间戳的起始时间为1970-01-01 00:00:00。
问题示例
以下请求中x-oss-user-last-modified的值为"Thu, 01 Jan 1970 00:00:00 GMT",等于起始时间,不符合"必须晚于1970-01-01 00:00:00"的要求。
PUT /example-object.txt HTTP/1.1
Host: example-bucket.oss-cn-hangzhou.aliyuncs.com
Date: Mon, 20 Mar 2024 10:30:00 GMT
x-oss-user-last-modified: Thu, 01 Jan 1970 00:00:00 GMT
Content-Length: 1234
Authorization: OSS LTAI****************:miAo****************
[Object Content]返回的错误信息如下:
HTTP/1.1 400 Bad Request
Server: AliyunOSS
Date: Mon, 20 Mar 2024 10:30:00 GMT
Content-Type: application/xml
Content-Length: 534
Connection: keep-alive
x-oss-request-id: 68C05BB8785D7A3133226E20
x-oss-server-time: 0
x-oss-ec: 0017-00000134
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>InvalidArgument</Code>
<Message>Invalid date. Must be later than 1970-01-01 00:00:00.</Message>
<RequestId>68C05BB8785D7A3133226E20</RequestId>
<HostId>example-bucket.oss-cn-hangzhou.aliyuncs.com</HostId>
<ArgumentName>x-oss-user-last-modified</ArgumentName>
<ArgumentValue>Thu, 01 Jan 1970 00:00:00 GMT</ArgumentValue>
<EC>0017-00000134</EC>
<RecommendDoc>https://api.aliyun.com/troubleshoot?q=0017-00000134</RecommendDoc>
</Error>解决方案
确保x-oss-user-last-modified请求头的值晚于1970-01-01 00:00:00(UTC时间)。
正确示例:
PUT /example-object.txt HTTP/1.1
Host: example-bucket.oss-cn-hangzhou.aliyuncs.com
Date: Mon, 20 Mar 2024 10:30:00 GMT
x-oss-user-last-modified: Wed, 15 Mar 2024 08:20:30 GMT
Content-Length: 1234
Authorization: OSS LTAI****************:miAo****************
[Object Content]关键要求:
日期格式必须符合HTTP日期格式(RFC 2616),例如:Wed, 15 Mar 2024 08:20:30 GMT
日期值必须晚于1970-01-01 00:00:00 GMT
如果不需要指定对象的最后修改时间,可以不设置此请求头,系统将使用对象实际的上传或修改时间
相关文档
关于上传对象的更多信息,请参见PutObject。
该文章对您有帮助吗?