API | 操作名 | 操作描述 |
查询存储桶列表 | 查询指定账号下所有的存储桶列表 | |
创建存储桶 | 在指定账号下创建一个存储桶 | |
检索存储桶及其权限 | 检索存储桶是否存在且是否有权限访问 | |
删除存储桶 | 删除指定账号下的空存储桶 |
// 获取所属账户的所有存储空间列表的方法QCloudGetServiceRequest* request = [[QCloudGetServiceRequest alloc] init];[request setFinishBlock:^(QCloudListAllMyBucketsResult* result,NSError* error) {// 从 result 中获取返回信息 存储桶列表NSArray<QCloudBucket*> *buckets = result.buckets;// bucket owner的信息QCloudOwner *owner = result.owner;}];[[QCloudCOSXMLService defaultCOSXML] GetService:request];
// 获取所属账户的所有存储空间列表的方法.let 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);
// 创建存储桶QCloudPutBucketRequest* request = [QCloudPutBucketRequest new];// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketrequest.bucket = @"examplebucket-1250000000";[request setFinishBlock:^(id outputObject, NSError* error) {// 可以从 outputObject 中获取服务器返回的 header 信息NSDictionary* info = (NSDictionary *) outputObject;}];[[QCloudCOSXMLService defaultCOSXML] PutBucket:request];
// 创建存储桶let putBucketReq = QCloudPutBucketRequest.init();// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketputBucketReq.bucket = "examplebucket-1250000000";putBucketReq.finishBlock = {(result,error) in// 可以从 result 中获取服务器返回的 header 信息if error != nil {print(error!);} else {print(result!);}}QCloudCOSXMLService.defaultCOSXML().putBucket(putBucketReq);
QCloudHeadBucketRequest* request = [QCloudHeadBucketRequest new];// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketrequest.bucket = @"examplebucket-1250000000";[request setFinishBlock:^(id outputObject, NSError* error) {// 可以从 outputObject 中获取服务器返回的 header 信息NSDictionary * result = (NSDictionary *)outputObject;}];[[QCloudCOSXMLService defaultCOSXML] HeadBucket:request];
let headBucketReq = QCloudHeadBucketRequest.init();// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketheadBucketReq.bucket = "examplebucket-1250000000";headBucketReq.finishBlock = {(result,error) inif let result = result {// result 包含响应的 header 信息} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().headBucket(headBucketReq);
// 存储桶名称,格式为 BucketName-APPID[[QCloudCOSXMLService defaultCOSXML] doesBucketExist: @"examplebucket-1250000000"];
// 存储桶名称,格式为 BucketName-APPIDQCloudCOSXMLService.defaultCOSXML().doesBucketExist("examplebucket-1250000000");
QCloudDeleteBucketRequest* request = [[QCloudDeleteBucketRequest alloc ] init];// 存储桶名称,命名格式:BucketName-APPIDrequest.bucket = @"examplebucket-1250000000";[request setFinishBlock:^(id outputObject,NSError*error) {// 可以从 outputObject 中获取服务器返回的 header 信息NSDictionary* info = (NSDictionary *) outputObject;}];[[QCloudCOSXMLService defaultCOSXML] DeleteBucket:request];
let deleteBucketReq = QCloudDeleteBucketRequest.init();// 存储桶名称,命名格式:BucketName-APPIDdeleteBucketReq.bucket = "examplebucket-1250000000";deleteBucketReq.finishBlock = {(result,error) inif let result = result {// result 包含响应的 header 信息} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().deleteBucket(deleteBucketReq);
本页内容是否解决了您的问题?