• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. API Reference (Python SDK)
  4. Bucket-Related APIs
  5. GET Bucket storageinfo

GET Bucket storageinfo

API Description

You can use this API to obtain storage information about a bucket, including the bucket size and number of objects in the bucket.

Method Definition

ObsClient.getBucketStorageInfo(bucketName)

Request Parameter

Field

Type

Optional or Mandatory

Description

bucketName

str

Mandatory

Bucket name

Returned Result

Type

Description

GetResult

SDK common result object

GetResult.body Type

Description

GetBucketStorageInfoResponse

Response result of GET Bucket storageinfo

Sample Code

try:
    resp = obsClient.getBucketStorageInfo('bucketname') 
     
    if resp.status < 300: 
        print('requestId:', resp.requestId) 
        print('size:', resp.body.size) 
        print('objectNumber:', resp.body.objectNumber) 
    else: 
        print('errorCode:', resp.errorCode) 
        print('errorMessage:', resp.errorMessage)
except:
    import traceback
    print(traceback.format_exc())