Help Center> Object Storage Service> SDK Reference> Java> Bucket Management> Setting or Obtaining a Bucket Quota

Setting or Obtaining a Bucket Quota

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

Setting a Bucket Quota

You can call ObsClient.setBucketQuota to set the bucket quota. Sample code is as follows:

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

// Set the bucket quota to 100 MB.
BucketQuota quota = new BucketQuota(1024 * 1024 * 100l);
obsClient.setBucketQuota("bucketname", quota);

A bucket quota must be a non-negative integer expressed in bytes. The maximum value is 263 - 1.

Obtaining a Bucket Quota

You can call ObsClient.getBucketQuota to obtain the bucket quota. Sample code is as follows:

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

BucketQuota quota = obsClient.getBucketQuota("bucketname");
System.out.println("\t" + quota.getBucketQuota());