API | 操作名 | 操作描述 |
设置存储桶策略 | 设置指定存储桶的权限策略 | |
查询存储桶策略 | 查询指定存储桶的权限策略 | |
删除存储桶策略 | 删除指定存储桶的权限策略 |
QCloudPutBucketPolicyRequest * request = [QCloudPutBucketPolicyRequest new];// 存储桶名称,由bucketname-appid 组成,appid必须填入,可以在COS控制台查看存储桶名称。 https://console.tencentcloud.com/cos5/bucketrequest.bucket = @"0-1250000000";request.regionName = @"ap-chengdu";// 权限策略,详情请参见 访问管理策略语法 https://www.tencentcloud.com/document/product/436/12469request.policyInfo = @{@"Statement": @[@{@"Principal": @{@"qcs": @[@"qcs::cam::uin/100000000001:uin/100000000001"]},@"Effect": @"allow",@"Action": @[@"name/cos:GetBucket"],@"Resource": @[@"qcs::cos:ap-guangzhou:uid/1250000000:examplebucket-1250000000/*"]}],@"version": @"2.0"};[request setFinishBlock:^(id _Nullable outputObject, NSError * _Nullable error) {}];[[QCloudCOSXMLService defaultCOSXML] PutBucketPolicy:request];
QCloudGetBucketPolicyRequest * request = [QCloudGetBucketPolicyRequest new];// 存储桶名称,由bucketname-appid 组成,appid必须填入,可以在COS控制台查看存储桶名称。 https://console.tencentcloud.com/cos5/bucketrequest.bucket = @"bucketname-appid";request.regionName = @"ap-chengdu";[request setFinishBlock:^(QCloudBucketPolicyResult * _Nullable outputObject, NSError * _Nullable error) {// QCloudBucketPolicyResult 详细字段请查看api文档或者SDK源码}];[[QCloudCOSXMLService defaultCOSXML] GetBucketPolicy:request];
// 存储桶名称,由bucketname-appid 组成,appid必须填入,可以在COS控制台查看存储桶名称。 https://console.tencentcloud.com/cos5/bucketQCloudDeleteBucketPolicyRequest * request = [QCloudDeleteBucketPolicyRequest new];request.bucket = @"0-1253960454";request.regionName = @"ap-chengdu";[request setFinishBlock:^(id _Nullable outputObject, NSError * _Nullable error) {/// error 为空则表示成功}];[[QCloudCOSXMLService defaultCOSXML] DeleteBucketPolicy:request];
本页内容是否解决了您的问题?