PutBucketLifecycle
Last Updated:2021-12-08
Interface Description
This interface is used to create the lifecycle management rules.
Description: Only the bucket owner with the FULL_CONTROL permission can initiate this request.
Request
-
Request syntax
PUT /?lifecycle HTTP/1.1 Host: <BucketName>.bj.bcebos.com x-bce-date: date Content-Length: request-body length Content-Type: application/json; charset=utf-8 Authorization: AuthorizationString { "rule": [ { "id": "rule-id", "status": "enabled", "resource": [ "bucket/prefix/*" ], "condition": { "time": { "dateGreaterThan": "2016-09-07T00:00:00Z" } }, "action": { "name": "DeleteObject" } }, }
-
Request header field
No special parameters.
-
Request parameters
Rule Item Description Required? Remarks rule List of rules Required List of all rules +id Rule ID. Required The rule ID in the same bucket must be unique and cannot be duplicated. If the user does not enter this field, the system automatically generates one for the user. +status Status of rules. Required The value is enabled
ordisabled
. The rule is not effective when it is in thedisabled
status.+resource For which resources is the rule effective? Required For example, the rule is effective for the object with prefix/ in samplebucket: samplebucket/prefix/*
. The rule is effective for all objects in samplebucket:samplebucket/*
.+condition Rule dependent conditions Required At present, it can be in the time form only. +time Time constraint Required It is implemented by the defined dateGreaterThan
.++dateGreaterThan Time relation description Required It can be the absolute time (date) and the relative time (days). The format of the absolute time (date) is yyyy-mm-ddThh:mm:ssZ, eg., 2016-09-07T00:00:00Z. The absolute time is the UTC time and must end with 00:00:00 (UTC 00:00). The description of the relative time (days) conforms to ISO8601, and the minimum time granularity supported is days. For example, $(lastModified)+P7D indicates the time for seven days after the last modification of the object. action Action performed on resource Required - +name Name of action performed Required The value is Transition
,DeleteObject
, orAbortMultipartUpload
.+storageClass Storage type of object Optional It can be set when the action is Transition
. For the bucket with non-multiple AZs, the value isSTANDARD_IA
,COLD
orARCHIVE
, indicating that the original storage type is switched to the infrequent access or cold storage or archive storage. For the bucket with multiple AZs, the value can beSTANDARD_IA
only, indicating that the original storage type is switched to the infrequent access.
Response
Example
-
Request example
PUT /?lifecycle HTTP/1.1 Host: bucket.bj.bcebos.com x-bce-date: 2016-08-16T08:23:49Z Content-Length :1324 Content-Type: application/json; charset=utf-8 Authorization: AuthorizationString { "rule": [ { "id": "sample-rule-delete-prefix", "status": "enabled", "resource": [ "bucket/prefix/*" ], "condition": { "time": { "dateGreaterThan": "2016-09-07T00:00:00Z" } }, "action": { "name": "DeleteObject" } }, { "id": "sample-rule-transition-prefix", "status": "enabled", "resource": [ "bucket/prefix/*" ], "condition": { "time": { "dateGreaterThan": "$(lastModified)+P7D" } }, "action": { "name": "Transition", "storageClass": "STANDARD_IA" } }, { "id": "sample-rule-abort-multiupload-prefix", "status": "enabled", "resource": [ "bucket/prefix/*" ], "condition": { "time": { "dateGreaterThan": "$(lastModified)+P7D" } }, "action": { "name": "AbortMultipartUpload" } } ] }
-
Response example
HTTP/1.1 200 OK x-bce-request-id: 0A49CE4060975EAC Date: Wed, 12 Oct 2016 17:50:00 GMT Content-Length: 0 Connection: keep-alive Server: BceBos