Versioning applies to all files (objects) in a bucket. Object versioning lets you recover an object to any of its previous versions if the object is overwritten or accidentally deleted.
Precautions
-
The sample code in this topic uses China (Hangzhou) with the region ID
cn-hangzhouas an example. A public endpoint is used by default. If you want to access OSS from other Alibaba Cloud products in the same region, you must use an internal endpoint. For more information about the mappings between regions and endpoints that OSS supports, see Regions and endpoints. -
To set the versioning status of a bucket, you must have the
oss:PutBucketVersioningpermission. To obtain information about the versioning status of a bucket, you must have theoss:GetBucketVersioningpermission. For more information, see Grant a custom access policy to a RAM user.
Sample code
References
-
For the complete sample code for setting the versioning status of a bucket, see PutBucketVersioning.cs.
-
For the complete sample code for obtaining the versioning status of a bucket, see GetBucketVersioning.cs.