GetBucketLifecycle接口用于查看存储空间(Bucket)的生命周期规则(Lifecycle)。只有Bucket的拥有者才有权限查看Bucket的生命周期规则。

请求语法

GET /?lifecycle HTTP/1.1
Host: BucketName.oss.aliyuncs.com
Date: GMT Date
Authorization: SignatureValue

示例

请求示例
Get /?lifecycle HTTP/1.1
Host: oss-example.oss.aliyuncs.com  
Date: Mon, 14 Apr 2014 01:17:29 GMT  
Authorization: OSS qn6qrrqxo2oawuk53otfjbyc:ceOEyZavKY4QcjoUWYSpYbJ3****
			
返回示例(已设置生命周期规则)
HTTP/1.1 200
x-oss-request-id: 534B371674E88A4D8906****
Date: Mon, 14 Apr 2014 01:17:29 GMT
Connection: keep-alive
Content-Length: 255
Server: AliyunOSS

<?xml version="1.0" encoding="UTF-8"?>
<LifecycleConfiguration>
  <Rule>
    <ID>delete after one day</ID>
    <Prefix>logs/</Prefix>
    <Status>Enabled</Status>
    <Expiration>
      <Days>1</Days>
    </Expiration>
  </Rule>
</LifecycleConfiguration>
			
返回示例(未设置生命周期规则)
HTTP/1.1 404
x-oss-request-id: 534B371674E88A4D8906****
Date: Mon, 14 Apr 2014 01:17:29 GMT
Connection: keep-alive
Content-Length: 278
Server: AliyunOSS

<?xml version="1.0" encoding="UTF-8"?>
<Error>
  <BucketName>oss-example</BucketName>
  <Code>NoSuchLifecycle</Code>
  <Message>No Row found in Lifecycle Table.</Message>
  <RequestId>534B372974E88A4D8906****</RequestId>
  <HostId> BucketName.oss.example.com</HostId>
</Error>

SDK

此接口所对应的各语言SDK如下:

错误码

错误码 HTTP 状态码 描述
AccessDenied 403 Forbidden 没有权限查看Bucket的生命周期规则。只有Bucket的拥有者才能查看Bucket的生命周期规则。
NoSuchBucket或NoSuchLifecycle 404 Not Found Bucket不存在或没有配置生命周期规则。