You can configure a time-based retention policy for an Object Storage Service (OSS) bucket. The retention policy has a retention period that ranges from 1 day to 70 years. This topic describes how to create, query, and lock a retention policy.
Usage notes
In this topic, the public endpoint of the China (Hangzhou) region is used. If you want to access OSS from other Alibaba Cloud services in the same region as OSS, use an internal endpoint. For more information about OSS regions and endpoints, see Regions and endpoints.
In this topic, access credentials are obtained from environment variables. For more information about how to configure access credentials, see Configure access credentials.
In this topic, an OSSClient instance is created by using an OSS endpoint. If you want to create an OSSClient instance by using custom domain names or Security Token Service (STS), see Configure OSSClient instances.
Sample code
Create a retention policy
Cancel an unlocked retention policy
Lock a retention policy
Obtain a retention policy
Extend the retention period for objects
References
For the complete sample code for retention policies, see GitHub examples.
For more information about how to create a retention policy, see InitiateBucketWorm.
For more information about how to cancel an unlocked retention policy, see AbortBucketWorm.
For more information about how to lock a retention policy, see CompleteBucketWorm.
For more information about how to obtain the configuration of a retention policy, see GetBucketWorm.
For more information about how to extend the retention period for objects, see ExtendBucketWorm.