Object-level retention (Object Worm) (Java SDK V2)
Object Worm enforces WORM (write once, read many) retention at the object level: each object gets its own retention mode and retain-until date, and can also be placed under legal hold. The following sections show how to use OSS SDK for Java V2 to enable Object Worm, query its configuration, set and query object retention, and manage legal hold.
Usage notes
The sample code in this topic uses the region ID
cn-hangzhouin the China (Hangzhou) region and the public endpoint by default. To access OSS from other Alibaba Cloud services deployed in the same region, use the internal endpoint instead. For the mapping between OSS regions and endpoints, see Regions and endpoints.
Sample code
Enable Object Worm and configure the default retention policy
Query Object Worm configuration
Set object retention
Query object retention
Set and query legal hold
References
For the synchronous sample code, see PutBucketObjectWormConfiguration.java.
For the asynchronous sample code, see PutBucketObjectWormConfigurationAsync.java.
For the synchronous sample code, see GetBucketObjectWormConfiguration.java.
For the asynchronous sample code, see GetBucketObjectWormConfigurationAsync.java.
For the synchronous sample code, see PutObjectRetention.java.
For the asynchronous sample code, see PutObjectRetentionAsync.java.
For the synchronous sample code, see GetObjectRetention.java.
For the asynchronous sample code, see GetObjectRetentionAsync.java.
For the synchronous sample code, see PutObjectLegalHold.java and GetObjectLegalHold.java.
For the asynchronous sample code, see PutObjectLegalHoldAsync.java and GetObjectLegalHoldAsync.java.