Setting Versioning Status for a Bucket
If you have any questions during development, post them on the Issues page of GitHub. For details about parameters and usage of each API, see the API Reference
You can call ObsClient.SetBucketVersioning to set the versioning status for a bucket. OBS supports two versioning statuses.
|
Versioning Status |
Description |
Value in OBS .NET SDK |
|---|---|---|
|
Enabled |
|
VersionStatusEnum.Enabled |
|
Suspended |
|
VersionStatusEnum.Suspended |
Sample code:
// Create an instance of ObsClient.
ObsClient client = new ObsClient("*** Provide your Access Key ***", "*** Provide your Secret Key ***", "https://your-endpoint");
// Set the versioning status.
try
{
SetBucketVersioningRequest request = new SetBucketVersioningRequest();
request.BucketName = "bucketname";
request.Configuration = new VersioningConfiguration();
//Enabling versioning.
request.VersioningConfig.Status = VersionStatusEnum.Enabled;
SetBucketVersioningResponse response = client.SetBucketVersioning(request);
Console.WriteLine("Set bucket version response: {0}", response.StatusCode);
}
catch (ObsException ex)
{
Console.WriteLine("ErrorCode: {0}", ex.ErrorCode);
Console.WriteLine("ErrorMessage: {0}", ex.ErrorMessage);
}
Last Article: Versioning Overview
Next Article: Viewing Versioning Status of a Bucket
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.