tencent cloud

Cloud Object Storage

Release Notes and Announcements
Release Notes
Announcements
Product Introduction
Overview
Features
Use Cases
Strengths
Concepts
Regions and Access Endpoints
Specifications and Limits
Service Regions and Service Providers
Billing
Billing Overview
Billing Method
Billable Items
Free Tier
Billing Examples
Viewing and Downloading Bill
Payment Overdue
FAQs
Getting Started
Console
Getting Started with COSBrowser
User Guide
Creating Request
Bucket
Object
Data Management
Batch Operation
Global Acceleration
Monitoring and Alarms
Operations Center
Data Processing
Content Moderation
Smart Toolbox
Data Processing Workflow
Application Integration
User Tools
Tool Overview
Installation and Configuration of Environment
COSBrowser
COSCLI (Beta)
COSCMD
COS Migration
FTP Server
Hadoop
COSDistCp
HDFS TO COS
GooseFS-Lite
Online Tools
Diagnostic Tool
Use Cases
Overview
Access Control and Permission Management
Performance Optimization
Accessing COS with AWS S3 SDK
Data Disaster Recovery and Backup
Domain Name Management Practice
Image Processing
Audio/Video Practices
Workflow
Direct Data Upload
Content Moderation
Data Security
Data Verification
Big Data Practice
COS Cost Optimization Solutions
Using COS in the Third-party Applications
Migration Guide
Migrating Local Data to COS
Migrating Data from Third-Party Cloud Storage Service to COS
Migrating Data from URL to COS
Migrating Data Within COS
Migrating Data Between HDFS and COS
Data Lake Storage
Cloud Native Datalake Storage
Metadata Accelerator
GooseFS
Data Processing
Data Processing Overview
Image Processing
Media Processing
Content Moderation
File Processing Service
File Preview
Troubleshooting
Obtaining RequestId
Slow Upload over Public Network
403 Error for COS Access
Resource Access Error
POST Object Common Exceptions
API Documentation
Introduction
Common Request Headers
Common Response Headers
Error Codes
Request Signature
Action List
Service APIs
Bucket APIs
Object APIs
Batch Operation APIs
Data Processing APIs
Job and Workflow
Content Moderation APIs
Cloud Antivirus API
SDK Documentation
SDK Overview
Preparations
Android SDK
C SDK
C++ SDK
.NET(C#) SDK
Flutter SDK
Go SDK
iOS SDK
Java SDK
JavaScript SDK
Node.js SDK
PHP SDK
Python SDK
React Native SDK
Mini Program SDK
Error Codes
Harmony SDK
Endpoint SDK Quality Optimization
Security and Compliance
Data Disaster Recovery
Data Security
Cloud Access Management
FAQs
Popular Questions
General
Billing
Domain Name Compliance Issues
Bucket Configuration
Domain Names and CDN
Object Operations
Logging and Monitoring
Permission Management
Data Processing
Data Security
Pre-signed URL Issues
SDKs
Tools
APIs
Agreements
Service Level Agreement
Privacy Policy
Data Processing And Security Agreement
Contact Us
Glossary

PUT Bucket lifecycle

PDF
Focus Mode
Font Size
Last updated: 2024-03-28 18:08:33

Feature Description

COS introduces the lifecycle feature for you to manage the lifecycle of objects in buckets. The lifecycle configuration contains one or more rules that apply to a set of objects. Each rule defines one operation. There are two types of operations:
Transition: defines when an object is transitioned to another storage class. For example, you can transition an object to STANDARD_IA (suitable for infrequently accessed objects) 30 days after its creation. You can also transition the object to INTELLIGENT TIERING (suitable for objects with irregular access patterns) or ARCHIVE (offering lower costs). For specific parameters, please see Transition in the sample request description.
Expiration: specifies when an object shall expire. COS will automatically delete expired objects.


Notes

This API (PUT Bucket lifecycle) is used to create a lifecycle configuration for a bucket.
Note:
If a lifecycle configuration has already been set for the bucket, the new configuration created with this API will overwrite the existing one.
Days and Date cannot be both specified in the same lifecycle rule. Please pass them to two separate rules. For details, please see the following Sample.
Objects in buckets with MAZ configuration enabled cannot be transitioned to an OAZ bucket.
Up to 1,000 lifecycle rules can be added for each bucket.

Requests

Request example

PUT /?lifecycle HTTP/1.1
Host: <BucketName-APPID>.cos.<Region>.myqcloud.com
Content-Length: length
Date: GMT Date
Authorization: Auth String
Content-MD5: MD5
Note:
In Host: <BucketName-APPID>.cos.<Region>.myqcloud.com, <BucketName-APPID> is the bucket name followed by the APPID, such as examplebucket-1250000000 (see Bucket Overview > Basic Information and Bucket Overview > Bucket Naming Conventions), and <Region> is a COS region (see Regions and Access Endpoints).
Authorization: Auth String (See Request Signature for details.)

Request headers

This API only uses Common Request Headers.

Request body

Nodes of the request body for this API are as follows:
<LifecycleConfiguration>
<Rule>
<ID></ID>
<Filter>
<And>
<Prefix></Prefix>
<Tag>
<Key></Key>
<Value></Value>
</Tag>
</And>
</Filter>
<Status></Status>
<Transition>
<Days></Days>
<StorageClass></StorageClass>
</Transition>
<NoncurrentVersionExpiration>
<NoncurrentDays></NoncurrentDays>
</NoncurrentVersionExpiration>
</Rule>
<Rule>
<ID></ID>
<Filter>
<Prefix></Prefix>
</Filter>
<Status></Status>
<Transition>
<Days></Days>
<StorageClass></StorageClass>
</Transition>
<NoncurrentVersionTransition>
<NoncurrentDays></NoncurrentDays>
<StorageClass></StorageClass>
</NoncurrentVersionTransition>
</Rule>
<Rule>
<ID></ID>
<Filter>
<Prefix></Prefix>
</Filter>
<Status></Status>
<Expiration>
<ExpiredObjectDeleteMarker></ExpiredObjectDeleteMarker>
</Expiration>
<NoncurrentVersionExpiration>
<NoncurrentDays></NoncurrentDays>
</NoncurrentVersionExpiration>
<AbortIncompleteMultipartUpload>
<DaysAfterInitiation></DaysAfterInitiation>
</AbortIncompleteMultipartUpload>
</Rule>
</LifecycleConfiguration>
The nodes are described as follows:
Node Name (Keyword)
Parent Node
Description
Type
Required
LifecycleConfiguration
None
Lifecycle configuration
Container
Yes
Rule
LifecycleConfiguration
Rule description
Container
Yes
ID
LifecycleConfiguration.Rule
A unique identifier for the rule. It can be up to 255 characters.
String
No
Filter
LifecycleConfiguration.Rule
Identifies objects that a lifecycle rule applies to.
Container
Yes
And
LifecycleConfiguration.Rule.Filter
A subset of the object filter. This element is only required when there are more than one filter criteria (for example, filtering with Prefix and Tag at the same time, or with more than one Tag).
Container
No
Prefix
LifecycleConfiguration.Rule.Filter.And
Matching prefix for the rule. It specifies objects that the lifecycle rule applies to. There can be one Prefix at most.
String
No
Tag
LifecycleConfiguration.Rule.Filter.And
A set of tags. Up to 10 tags are supported.
Container
No
Key
LifecycleConfiguration.Rule.Filter.And.Tag
Key of the tag. It can be up to 128 bytes. Letters, digits, spaces, plus signs (+), minus signs (-), underscores (_), equal signs (=), dots (.), colons (:), and slashes (/) are supported.
String
No
Value
LifecycleConfiguration.Rule.Filter.And.Tag
Value of the tag. It can be up to 256 bytes. Letters, digits, spaces, plus signs (+), minus signs (-), underscores (_), equal signs (=), dots (.), colons (:), and slashes (/) are supported.
String
No
Status
LifecycleConfiguration.Rule
Indicates whether the rule is enabled. Enumerated values: Enabled, Disabled
String
Yes
Expiration
LifecycleConfiguration.Rule
Expiration attributes of the rule
Container
No
Transition
LifecycleConfiguration.Rule
Specifies when to transition the object and the target storage class.
Container
No
Days
LifecycleConfiguration.Rule.Transition or Expiration
Specifies the number of days between the date an object was last modified and the date when the operation corresponding to the rule is performed.
If it is a Transition operation, this value should be a non-negative integer.
If it is an Expiration operation, this value should be a positive integer. The maximum value is 3650 (days).
Integer
No
ExpiredObjectDeleteMarker
LifecycleConfiguration.Rule.Expiration
Indicates whether the delete marker of an expired object will be removed. Enumerated values: true, false
String
No
AbortIncompleteMultipartUpload
LifecycleConfiguration.Rule
Specifies the time to abort the multipart upload.
Container
No
DaysAfterInitiation
LifecycleConfiguration.Rule.AbortIncompleteMultipartUpload
Specifies the number of days within which the multipart upload must be completed after it starts.
Integer
Yes
NoncurrentVersionExpiration
LifecycleConfiguration.Rule
Specifies when noncurrent object versions shall expire.
Container
No
NoncurrentVersionTransition
LifecycleConfiguration.Rule
Specifies when to transition objects of noncurrent versions and the target storage class.
Container
No
NoncurrentDays
LifecycleConfiguration.Rule.NoncurrentVersionExpiration or NoncurrentVersionTransition
Specifies the number of days between the date when an object becomes noncurrent and the date when the operation corresponding to a rule is performed.
If it is a Transition operation, this value should be a non-negative integer.
If it is an Expiration operation, this value should be a positive integer. The maximum value is 3650 (days).
Integer
No
StorageClass
LifecycleConfiguration.Rule.Transition or NoncurrentVersionTransition
Specifies the storage class of the transitioned object. Enumerated values: STANDARD_IA, MAZ_STANDARD_IA, INTELLIGENT_TIERING, MAZ_INTELLIGENT_TIERING, ARCHIVE, DEEP_ARCHIVE. For more information about storage classes, see Storage Class Overview.
String
Yes

Response

Response headers

This API only returns Common Response Headers.

Response body

The response body is empty.

Error codes

This API returns common error responses and error codes. For more information, see Error Codes.

Examples

Request

PUT /?lifecycle HTTP/1.1
Host:examplebucket-1250000000.cos.ap-beijing.myqcloud.com
Date: Wed, 16 Aug 2017 11:59:33 GMT
Authorization:q-sign-algorithm=sha1&q-ak=AKIDZfbOAo7cllgPvF9cXFrJD0a1ICvR****&q-sign-time=1502855771;1502935771&q-key-time=1502855771;1502935771&q-header-list=content-md5;host&q-url-param-list=lifecycle&q-signature=f3aa2c708cfd8d4d36d658de56973c9cf1c2****
Content-MD5: LcNUuow8OSZMrEDnvndw1Q==
Content-Length: 348
Content-Type: application/x-www-form-urlencoded



<LifecycleConfiguration>
<Rule>
<ID>id1</ID>
<Filter>
<Prefix>documents/</Prefix>
</Filter>
<Status>Enabled</Status>
<Transition>
<Days>100</Days>
<StorageClass>ARCHIVE</StorageClass>
</Transition>
</Rule>
<Rule>
<ID>id2</ID>
<Filter>
<Prefix>logs/</Prefix>
</Filter>
<Status>Enabled</Status>
<Transition>
<Days>10</Days>
<StorageClass>STANDARD_IA</StorageClass>
</Transition>
</Rule>
</LifecycleConfiguration>

Response

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 0
Date: Wed, 16 Aug 2017 11:59:33 GMT
Server: tencent-cos
x-cos-request-id: NTk5NDMzYTRfMjQ4OGY3Xzc3NGRf****


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback