Deleting Versioning Objects
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
Deleting a Single Versioning Object
You can call ObsClient.DeleteObject to pass the version ID (VersionId) to delete a versioning object. Sample code is as follows:
// Create an instance of ObsClient.
ObsClient client = new ObsClient("*** Provide your Access Key ***", "*** Provide your Secret Key ***", "https://your-endpoint");
// Delete a versioning object.
try
{
DeleteObjectRequest request = new DeleteObjectRequest()
{
BucketName = "buckername",
ObjectKey = "objectname",
VersionId = "versionId"
};
DeleteObjectResponse response = client.DeleteObject(request);
Console.WriteLine("Delete object response: {0}", response.StatusCode);
}
catch (ObsException ex)
{
Console.WriteLine("ErrorCode: {0}", ex.ErrorCode);
Console.WriteLine("ErrorMessage: {0}", ex.ErrorMessage);
}
Deleting Versioning Objects in a Batch
You can call ObsClient.DeleteObjects to pass the version ID (VersionId) of each to-be-deleted object to delete them. Sample code is as follows:
// Create an instance of ObsClient.
ObsClient client = new ObsClient("*** Provide your Access Key ***", "*** Provide your Secret Key ***", "https://your-endpoint");
// Delete two versioning objects.
try
{
DeleteObjectsRequest request = new DeleteObjectsRequest();
request.BucketName = "bucketname";
request.Quiet = true;
request.AddKey("objectName1", "versionId1");
request.AddKey("objectName2", "versionId2");
DeleteObjectsResponse response = client.DeleteObjects(request);
Console.WriteLine("Delete objects response: {0}", response.StatusCode);
}
catch (ObsException ex)
{
Console.WriteLine("ErrorCode: {0}", ex.ErrorCode);
Console.WriteLine("ErrorMessage: {0}", ex.ErrorMessage);
}
Last Article: Setting or Obtaining a Versioning Object ACL
Next Article: Lifecycle Management
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.