API | Operation | Description |
Setting a bucket policy | Sets a permission policy for the specified bucket | |
Querying bucket policy | Queries the permission policy of the specified bucket | |
Deleting bucket policies | Deletes the permission policies of a specified bucket |
QCloudPutBucketPolicyRequest * request = [QCloudPutBucketPolicyRequest new];// Bucket name in the format of `BucketName-APPID` (`APPID` is required), which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket.request.bucket = @"0-1250000000";request.regionName = @"ap-chengdu";// Permission policy. For more information, see [CAM Practices > Policy Syntax](https://www.tencentcloud.com/document/product/436/12469).request.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];// Bucket name in the format of `BucketName-APPID` (`APPID` is required), which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket.request.bucket = @"bucketname-appid";request.regionName = @"ap-chengdu";[request setFinishBlock:^(QCloudBucketPolicyResult * _Nullable outputObject, NSError * _Nullable error) {// For detailed fields in `QCloudBucketPolicyResult`, see the API documentation or SDK source code.}];[[QCloudCOSXMLService defaultCOSXML] GetBucketPolicy:request];
// Bucket name in the format of `BucketName-APPID` (`APPID` is required), which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket.QCloudDeleteBucketPolicyRequest * request = [QCloudDeleteBucketPolicyRequest new];request.bucket = @"0-1253960454";request.regionName = @"ap-chengdu";[request setFinishBlock:^(id _Nullable outputObject, NSError * _Nullable error) {/// If `error` is null, the request is successful.}];[[QCloudCOSXMLService defaultCOSXML] DeleteBucketPolicy:request];
Was this page helpful?