You need to enable JavaScript to run this app.
Torch Object Storage

Torch Object Storage

Copy page
Download PDF
Basic Bucket Interface
Deleting a Bucket (C++ SDK)
Copy page
Download PDF
Deleting a Bucket (C++ SDK)
When you no longer need to retain a bucket (Bucket), you may delete it to avoid incurring additional charges.​
Precautions​
  • Once a bucket is deleted, it cannot be restored. Please proceed with caution.​
  • Before deleting a bucket, you must have the tos:DeleteBucket permission. For detailed instructions, please refer to the Permission Configuration Guide.​
Prerequisites​
Before deleting a bucket, ensure that all data within the bucket has been removed.​
  • If versioning is enabled for the bucket, please ensure that all current and historical version objects within the bucket have been deleted. For detailed instructions, see Delete Object.​
  • If there are unmerged shards in the bucket, ensure that all shard data is deleted. For specific operations, refer to Delete Shard.​
  • If your bucket contains a large number of objects, you can configure lifecycle rules to enable batch deletion of objects. For detailed instructions, please refer to Setting Lifecycle Rules.​
Sample Code​
The following code is used to delete the bucket examplebucket.​
​
#include "TosClientV2.h"​
using namespace VolcengineTos;​
​
int main(void){​
​
​
std::string region = "Your Region";​
std::string accessKey = std::getenv("TOS_ACCESS_KEY");​
std::string secretKey = std::getenv("TOS_SECRET_KEY");​
​
std::string bucketName = "examplebucket";​
​
​
InitializeClient();​
​
TosClientV2 client(region, accessKey, secretKey);​
​
​
DeleteBucketInput input(bucketName);​
auto output = client.deleteBucket(input);​
if (!output.isSuccess()) {​
​
std::cout << "DeleteBucket failed." << output.error().String() << std::endl;​
​
CloseClient();​
return -1;​
}​
std::cout << "DeleteBucket success." << std::endl;​
​
​
CloseClient();​
return 0;​
}​
​
Relevant Documentation​
For API documentation on deleting buckets, refer to DeleteBucket.​
Last updated: 2025.09.25 14:22:45