OSS on CloudBox buckets are returned in lexicographic order. For a given cloud box, you can list all buckets it contains, buckets whose names start with a specific prefix, or a paginated subset of buckets.
Prerequisites
Before you begin, ensure that you have:
An OSS on CloudBox deployment in one of the supported regions: China (Hangzhou), China (Shanghai), China (Shenzhen), China (Heyuan), China (Beijing), or China (Chengdu)
A cloud box purchased. For more information, see Purchase a cloud box
A Virtual Private Cloud (VPC) and a vSwitch created in the OSS on CloudBox. For more information, see Create a VPC and a vSwitch
A VPC internal network set up with a single tunnel configured for secure connection. To apply for this feature, contact technical support
Parameters
Use the following parameters to filter and paginate results.
| Parameter | Description | Default |
|---|---|---|
prefix | Returns only buckets whose names start with the specified prefix. | All buckets in the cloud box |
marker | Returns buckets whose names are lexicographically after the specified value. To paginate through results, set this to the name of the last bucket returned by the previous call. | All buckets in the cloud box |
max-keys | Maximum number of buckets to return. Valid values: 1–1000. | 100 |
List buckets using OSS SDK for Java
Only OSS SDK for Java 3.15.0 or later supports listing OSS on CloudBox buckets. The SDK uses Signature Version 4 and requires a CloudBox-specific client configuration.
Step 1: Initialize the client
import com.aliyun.oss.ClientBuilderConfiguration;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.common.auth.CredentialsProviderFactory;
import com.aliyun.oss.common.auth.DefaultCredentialProvider;
import com.aliyun.oss.common.auth.EnvironmentVariableCredentialsProvider;
import com.aliyun.oss.common.comm.SignVersion;
// Endpoint of the cloud box
String endpoint = "https://cb-f8z7yvzgwfkl9q0h****.cn-hangzhou.oss-cloudbox.aliyuncs.com";
// Region where the cloud box is located
String region = "cn-hangzhou";
// ID of the cloud box
String cloudBoxId = "cb-f8z7yvzgwfkl9q0h****";
// Load credentials from environment variables OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET
EnvironmentVariableCredentialsProvider credentialsProvider =
CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
ClientBuilderConfiguration conf = new ClientBuilderConfiguration();
conf.setSignatureVersion(SignVersion.V4);
OSS ossClient = OSSClientBuilder.create()
.endpoint(endpoint)
.credentialsProvider(new DefaultCredentialProvider(credentialsProvider.getCredentials()))
.clientConfiguration(conf)
.region(region)
.cloudBoxId(cloudBoxId)
.build();Step 2: List buckets
import com.aliyun.oss.ClientException;
import com.aliyun.oss.OSSException;
import com.aliyun.oss.model.Bucket;
import java.util.List;
try {
// List all buckets in the cloud box
List<Bucket> buckets = ossClient.listBuckets();
for (Bucket bucket : buckets) {
System.out.println(" - " + bucket.getName());
}
// Sample output:
// - my-cloudbox-bucket-a
// - my-cloudbox-bucket-b
} catch (OSSException oe) {
System.out.println("Error Message: " + oe.getErrorMessage());
System.out.println("Error Code: " + oe.getErrorCode());
System.out.println("Request ID: " + oe.getRequestId());
System.out.println("Host ID: " + oe.getHostId());
} catch (ClientException ce) {
System.out.println("Error Message: " + ce.getMessage());
} finally {
if (ossClient != null) {
ossClient.shutdown();
}
}List buckets using ossutil
List buckets using the OSS API
For custom integrations that require direct HTTP calls, use the ListBuckets (GetService) operation. Your code must include signature calculation. For more information, see ListBuckets (GetService).