Listing Buckets
You can call listBuckets to list buckets. 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];
// List buckets.
OBSListBucketsRequest *request = [OBSListBucketsRequest new];
[client listBuckets:request completionHandler:^(OBSListBucketsResponse *response, NSError *error) {
for(OBSBucket *bucket in response.bucketsList){
NSLog(@"bucketname=%@",bucket.name);
}
}];
Obtained bucket names are listed in the lexicographical order.
Last Article: Creating a Bucket
Next Article: Deleting a Bucket
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.