• Object Storage Service

  1. Help Center
  2. Object Storage Service
  3. Developer Guide (Python SDK)
  4. Bucket Management
  5. Obtaining Storage Information About a Bucket

Obtaining Storage Information About a Bucket

The storage information about a bucket includes the used capacity of and the number of objects in the bucket. You can call ObsClient.getBucketStorageInfo to obtain the bucket storage information. Sample code is as follows:

# Import the module.
from com.obs.client.obs_client import ObsClient

# Create an instance of ObsClient.
obsClient = ObsClient(
    access_key_id='*** Provide your Access Key ***',    
    secret_access_key='*** Provide your Secret Key ***',    
resp = obsClient.getBucketStorageInfo('bucketname')

if resp.status < 300:
    print('requestId:', resp.requestId)
    print('size:', resp.body.size)
    print('objectNumber:', resp.body.objectNumber)
    print('errorCode:', resp.errorCode)
    print('errorMessage:', resp.errorMessage)