• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. Developer Guide (Java SDK)
  4. Bucket Management
  5. Deleting a Bucket

Deleting a Bucket

You can call ObsClient.deleteBucket to delete a bucket. Sample code is as follows:

String endPoint = "yourdomainname";
String ak = "*** Provide your Access Key ***";
String sk = "*** Provide your Secret Key ***";
// Create an instance of ObsClient.
ObsClient obsClient = new ObsClient(ak, sk, endPoint);

// Delete a bucket.
obsClient.deleteBucket("bucketname");

// Close obsClient.
obsClient.close();
NOTE:
  • Only empty buckets (without objects and part fragments) can be deleted.
  • Bucket deletion is a non-idempotence operation and an error will be reported if the to-be-deleted bucket does not exist.