• Object Storage Service

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

Setting or Obtaining a Bucket Quota

Setting a Bucket Quota

You can call ObsClient.setBucketQuota to set the bucket quota. 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);

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

// Close obsClient.
obsClient.close();
NOTE:

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 = "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);

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

// Close obsClient.
obsClient.close();