Help Center> Object Storage Service> SDK Reference> iOS> Bucket Management> Obtaining Storage Information About a Bucket

Obtaining Storage Information About a Bucket

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

static OBSClient *client;
NSString *endPoint = @"your-endpoint";
NSString *SK = @"*** Provide your Secret Key ***";
NSString *AK = @"*** Provide your Access Key ***";
    
// Initialize identity authentication.
OBSStaticCredentialProvider *credentialProvider = [[OBSStaticCredentialProvider alloc] initWithAccessKey:AK secretKey:SK];
    
//Initialize service configuration.
OBSServiceConfiguration *conf = [[OBSServiceConfiguration alloc] initWithURLString:endPoint credentialProvider:credentialProvider];
    
// Initialize an instance of OBSClient.
client = [[OBSClient alloc] initWithConfiguration:conf];
    
// Obtain the storage information about a bucket.
OBSGetBucketStorageInfoRequest *request = [[OBSGetBucketStorageInfoRequest alloc] initWithBucketName:@"bucketname"];
    
[client getBucketStorageInfo:request completionHandler:^(OBSGetBucketStorageInfoResponse *response, NSError *error) {
    NSLog(@"%@",response.storageinfo);
 }];