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

Torch Object Storage

Copy page
Download PDF
Vector bucket
DeleteVectorBucket(TOS Vectors Java SDK)
Copy page
Download PDF
DeleteVectorBucket(TOS Vectors Java SDK)
The deleteVectorBucket interface is used to delete a specified vector bucket. This article explains how to delete a bucket using the deleteVectorBucket interface in the TOS Vectors Java SDK.​
Notes​
  • You need to fill in the region and access domain in the example code according to your actual situation. For details, see Regions and Endpoints.​
  • To prevent key leakage, the example code reads the Access Key ID and Secret Access Key from environment variables. Before using the SDK, you need to configure long-term access credentials. For details, see Configuring Long-Term Access Credentials.​
  • The TOS Vectors Java SDK supports temporary access credentials and allows configuration of timeout mechanisms, retry policies, and other settings. You can adjust these flexibly to improve application security. For details, see Common Configuration Scenarios.​
  • Before deleting a vector bucket, ensure the bucket is empty, meaning all vector indexes in the bucket have been deleted.​
Permissions required​
The root account has full permissions by default, while IAM users have no permissions by default. If you need to use a sub-account to perform the deleteVectorBucket operation, the main account must grant the following permissions to the sub-account through IAM policy and bucket policy:​
tosvectors:DeleteVectorBucket​
Code example​
Basic usage of deleting a vector bucket​
​
// Basic usage of deleting vector buckets.​
package org.example.DeleteVectorBucket;​
​
import com.volcengine.tos.TOSVectorsClientBuilder;​
import com.volcengine.tos.TOSVectors;​
import com.volcengine.tos.TosClientException;​
import com.volcengine.tos.TosServerException;​
import com.volcengine.tos.model.vectors.DeleteVectorBucketInput;​
import com.volcengine.tos.model.vectors.DeleteVectorBucketOutput;​
​
public class DeleteVectorBucketExample {​
public static void main(String[] args) {​
String endpoint = 'Provide your endpoint';​
String region = 'Provide your region';​
String accessKey = System.getenv("TOS_ACCESS_KEY");​
String secretKey = System.getenv("TOS_SECRET_KEY");​
​
// Fill in the vector bucket name.​
String vectorBucketName = 'Provide your bucket name';​
// Fill in the account ID (optional parameter).​
String accountId = System.getenv("TOS_ACCOUNT_ID");​
​
// Initialize client.​
TOSVectors client = new TOSVectorsClientBuilder().build(region, endpoint, accessKey, secretKey);​
​
try {​
// Construct a request to delete a vector bucket.​
DeleteVectorBucketInput input = DeleteVectorBucketInput.builder()​
.vectorBucketName(vectorBucketName)​
.accountId(accountId)​
.build();​
​
// Perform deletion operation.​
DeleteVectorBucketOutput output = client.deleteVectorBucket(input);​
​
// Print result information.​
System.out.println("Delete vector bucket successfully");​
System.out.println("RequestID: " + output.getRequestInfo().getRequestId());​
System.out.println("StatusCode: " + output.getRequestInfo().getStatusCode());​
​
} catch (TosClientException e) {​
// Operation failed, caught Client exception. Generally, it is a request parameter error, and in this case, the request was not sent.​
System.out.println("Operation failed");​
System.out.println("Message: " + e.getMessage());​
if (e.getCause() != null) {​
e.getCause().printStackTrace();​
}​
} catch (TosServerException e) {​
// Operation failed, server exception captured, and detailed error information returned from the server can be obtained.​
System.out.println("Operation failed");​
System.out.println("StatusCode: " + e.getStatusCode());​
System.out.println("Code: " + e.getCode());​
System.out.println("Message: " + e.getMessage());​
System.out.println("RequestID: " + e.getRequestID());​
} catch (Throwable t) {​
// As a fallback to catch other exceptions, it generally won't execute here.​
System.out.println("Operation failed");​
System.out.println("unexpected exception, message: " + t.getMessage());​
}​
}​
}​
​
Related documentation​
For the API documentation of DeleteVectorBucket, see DeleteVectorBucket.​
Last updated: 2026.02.06 18:01:47