Content is empty
If you don't find the content you expect, please try another search term
Last updated:2021-09-14 16:18:08
You can call this operation to create a lifecycle configuration for a bucket. If a lifecycle configuration has been created for the bucket, the new lifecycle configuration replaces the existing lifecycle configuration. To prevent a misoperation, take note of this point.
After you create a lifecycle configuration for the bucket, Kingsoft Cloud Standard Storage Service (KS3) automatically deletes objects to which lifecycle rules apply or converts the storage classes of the objects.
— Permission description:
To use this operation, you must be the owner of the bucket or have permission to perform the ks3:PutBucketLifecycle action.
PUT /?lifecycle HTTP/1.1
Host: {BucketName}.{endpoint}
Date: {date}
Authorization: {SignatureValue}
Content-length: {length}
Content-MD5: {md5}
Lifecycle configuration in the request body
References:
No request parameter is used.
Except for common request headers, this operation must include the Content-MD5 header, as described in the following table.
Header | Description | Required |
---|---|---|
Content-MD5 | The 128-bit MD5 digest of data that is Base64-encoded. You must include the Content-MD5 header in this operation to verify that the request body is not corrupted. For more information, see RFC-1864. Type: String Default value: None |
Yes |
The following XML file describes a lifecycle configuration:
<LifecycleConfiguration>
<Rule>
<ID>id1</ID>
<Filter>
<Prefix>documents</Prefix>
</Filter>
<Expiration>
<Date>2016-12-31T00:00:00.000Z</Date>
</Expiration>
<Status>Enabled</Status>
</Rule>
<Rule>
<ID>id2</ID>
<Filter>
<Prefix>logs</Prefix>
</Filter>
<Expiration>
<Days>130</Days>
</Expiration>
<Transition>
<Days>10</Days>
<StorageClass>STANDARD_IA</StorageClass>
</Transition>
<Transition>
<Days>40</Days>
<StorageClass>ARCHIVE</StorageClass>
</Transition>
<Status>Enabled</Status>
</Rule>
<Rule>
<ID>id3</ID>
<Filter>
<Prefix>pic</Prefix>
</Filter>
<Status>Enabled</Status>
<Expiration>
<Date>2018-01-01T00:00:00.000Z</Date>
</Expiration>
</Rule>
<Rule>
<ID>id4</ID>
<Filter>
<And>
<Prefix>123</Prefix>
<Tag>
<Key>age</Key>
<Value>21</Value>
</Tag>
<Tag>
<Key>name</Key>
<Value>li</Value>
</Tag>
</And>
</Filter>
<Status>Enabled</Status>
<Expiration>
<Date>2021-01-01T00:00:00.000Z</Date>
</Expiration>
</Rule>
</LifecycleConfiguration>
The Rule node indicates a lifecycle rule and contains the following child nodes:
Note:
The following table describes the nodes in an XML file.
Name | Description | Required |
---|---|---|
LifecycleConfiguration | The container that contains multiple rules. A bucket can have up to 1,000 lifecycle rules. Type: Container Child node: Rule Parent node: None |
Yes |
Rule | The rule. Type: Container Parent node: LifecycleConfiguration |
Yes |
ID | The ID of the rule, which must unique in a bucket. The ID can be up to 255 UTF-8 characters, not bytes, in length. Type: String Parent node: Rule |
Yes |
Filter | The filter. A rule can have only one filter. Different rules cannot share a prefix-based filter. Type: Container Child node: Prefix Parent node: Rule |
No |
And | A subset of filters. This node is required only when you specify multiple filters. If you want to filter objects by prefix and tag at the same time, or specify multiple tags to filter objects, you can use this node. Type: Container Parent node: LifecycleConfiguration.Rule.Filter |
No |
Prefix | The prefix of the object key. Only objects whose key matches the prefix are deleted. A rule can have only one filter and one prefix. Type: String Parent node: Filter |
No |
Tag | The collection of tags, which supports up to 10 tags. Type: Container |
No |
Key | The key of the tag. A valid key can be up to 128 bytes in length, and can contain letters, digits, spaces, and the following special characters: plus signs (+), minus signs (-), equal signs (=), periods (.), underscores (_), colons (:), and forward slashes (/). Type: String |
No |
Value | The value of the tag. A valid value can be up to 256 bytes in length, and can contain letters, digits, spaces, and the following special characters: plus signs (+), minus signs (-), equal signs (=), periods (.), underscores (_), colons (:), and forward slashes (/). Type: String |
No |
Status | The status of the rule. If the rule is in the Enabled state, the rule takes effect as scheduled. If the rule is in the Disabled state, the rule cannot take effect. In this case, the rule is not deleted and can be enabled at any time. Type: String Parent node: Rule Valid values: Enabled and Disabled |
Yes |
Expiration | Specifies the date at which the object expires or the lifetime, in days, of the object. Type: Container Child node: Days and Date Parent node: Rule |
Yes |
Date | The date for deleting objects. Objects whose last modification date is earlier than this value will be deleted. The date must be in the ISO 8601 standard in the YYYY-MM-DDThh:mm:ss+08:00 format. You must set hh:mm:ss to 00:00:00. Type: String Parent nodes: Expiration and Transition |
Yes (if Days is unavailable) |
Days | The number of days (counted from the last modification date) after which the corresponding object will be deleted. The value must be greater than zero. Type: Integer Parent nodes: Expiration and Transition |
Yes (if Date is unavailable) |
Transition | The time to convert the storage class of the specified object between IA and Archive during the lifecycle of this object. Type: Container Child node: Days, Date, and StorageClass |
No |
StorageClass | The storage class for storing the specified object. Parent node: Transition Valid values: STANDARD_IA and ARCHIVE (not supported if the AWS SDK is used in the console) |
No (Yes if Transition is available) |
Notes:
This operation involves only common response headers. For more information, see Common response headers.
No response body is returned.
This operation does not return operation-specific errors.
PUT /?lifecycle HTTP/1.1
Host: ks3-example.ks3-cn-beijing.ksyuncs.com
Date: Wed, 14 May 2014 02:11:21 GMT
Content-MD5: xxx
Authorization: authorization string
Content-Length: yyy
Content-type: application/xml
<LifecycleConfiguration>
<Rule>
<ID>id1</ID>
<Filter>
<Prefix>documents</Prefix>
</Filter>
<Expiration>
<Date>2016-12-31T00:00:00+08:00</Date>
</Expiration>
<Status>Enabled</Status>
</Rule>
<Rule>
<ID>id2</ID>
<Filter>
<Prefix>logs</Prefix>
</Filter>
<Expiration>
<Days>130</Days>
</Expiration>
<Transition>
<Days>10</Days>
<StorageClass>STANDARD_IA</StorageClass>
</Transition>
<Transition>
<Days>40</Days>
<StorageClass>ARCHIVE</StorageClass>
</Transition>
<Status>Enabled</Status>
</Rule>
<Rule>
<ID>id3</ID>
<Filter>
<And>
<Prefix>docs</Prefix>
<Tag>
<Key>age</Key>
<Value>21</Value>
</Tag>
<Tag>
<Key>name</Key>
<Value>li</Value>
</Tag>
</And>
</Filter>
<Status>Enabled</Status>
<Expiration>
<Date>2021-01-01T00:00:00.000Z</Date>
</Expiration>
</Rule>
</LifecycleConfiguration>
The preceding XML file specifies three lifecycle rules in a bucket.
HTTP/1.1 200 OK
Content-Length: 0
Date: Tue, 19 Jul 2017 09:14:23 GMT
Server: Tengine
x-kss-request-id: 54a47bda18ac4e6e91de369add54218***
Note: For more information, see Lifecycle management.
Pure Mode