API | Operation | Description |
Querying a bucket list | Queries the list of all buckets under a specified account | |
Creating a bucket | Creates a bucket under a specified account | |
Checking a bucket and its permissions | Checks whether a bucket exists and whether you have permission to access it | |
Deleting a bucket | Deletes an empty bucket from a specified account |
// Method for getting the list of all storage spaces under an accountQCloudGetServiceRequest* request = [[QCloudGetServiceRequest alloc] init];[request setFinishBlock:^(QCloudListAllMyBucketsResult* result,NSError* error) {//Get the returned information from resultNSArray<QCloudBucket*> *buckets = result.buckets;// Bucket ownerQCloudOwner *owner = result.owner;}];[[QCloudCOSXMLService defaultCOSXML] GetService:request];
// Method for getting the list of all storage spaces under an accountlet getServiceReq = QCloudGetServiceRequest.init();getServiceReq.setFinish{(result,error) inif let result = result {let buckets = result.bucketslet owner = result.owner} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().getService(getServiceReq);
PUT Bucket
) is used to create a bucket.// Create a bucketQCloudPutBucketRequest* request = [QCloudPutBucketRequest new];// Bucket name in the format of `BucketName-APPID`, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket.request.bucket = @"examplebucket-1250000000";[request setFinishBlock:^(id outputObject, NSError* error) {// You can get the header information returned by the server from outputObjectNSDictionary* info = (NSDictionary *) outputObject;}];[[QCloudCOSXMLService defaultCOSXML] PutBucket:request];
// Create a bucketlet putBucketReq = QCloudPutBucketRequest.init();// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket.putBucketReq.bucket = "examplebucket-1250000000";putBucketReq.finishBlock = {(result,error) in// You can get the header information returned by the server from resultif error != nil {print(error!);} else {print(result!);}}QCloudCOSXMLService.defaultCOSXML().putBucket(putBucketReq);
QCloudHeadBucketRequest* request = [QCloudHeadBucketRequest new];// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket.request.bucket = @"examplebucket-1250000000";[request setFinishBlock:^(id outputObject, NSError* error) {// You can get the header information returned by the server from outputObjectNSDictionary * result = (NSDictionary *)outputObject;}];[[QCloudCOSXMLService defaultCOSXML] HeadBucket:request];
let headBucketReq = QCloudHeadBucketRequest.init();// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket.headBucketReq.bucket = "examplebucket-1250000000";headBucketReq.finishBlock = {(result,error) inif let result = result {// result contains response headers} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().headBucket(headBucketReq);
// Bucket name in the format of BucketName-APPID[[QCloudCOSXMLService defaultCOSXML] doesBucketExist: @"examplebucket-1250000000"];
// Bucket name in the format of BucketName-APPIDQCloudCOSXMLService.defaultCOSXML().doesBucketExist("examplebucket-1250000000");
QCloudDeleteBucketRequest* request = [[QCloudDeleteBucketRequest alloc ] init];// Bucket name in the format of BucketName-APPIDrequest.bucket = @"examplebucket-1250000000";[request setFinishBlock:^(id outputObject,NSError*error) {// You can get the header information returned by the server from outputObjectNSDictionary* info = (NSDictionary *) outputObject;}];[[QCloudCOSXMLService defaultCOSXML] DeleteBucket:request];
let deleteBucketReq = QCloudDeleteBucketRequest.init();// Bucket name in the format of BucketName-APPIDdeleteBucketReq.bucket = "examplebucket-1250000000";deleteBucketReq.finishBlock = {(result,error) inif let result = result {// result contains response headers} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().deleteBucket(deleteBucketReq);
Apakah halaman ini membantu?