API | 操作名 | 操作描述 |
设置存储桶 ACL | 设置指定存储桶的访问权限控制列表(ACL) | |
查询存储桶 ACL | 查询指定存储桶的访问权限控制列表(ACL) |
API | 操作名 | 操作描述 |
设置对象 ACL | 设置存储桶中某个对象的访问控制列表 | |
查询对象 ACL | 查询对象的访问控制列表 |
QCloudPutBucketACLRequest* putACL = [QCloudPutBucketACLRequest new];// 授予权限的账号 IDNSString* uin = @"100000000001";NSString *ownerIdentifier = [NSString stringWithFormat:@"qcs::cam::uin/%@:uin/%@", uin,uin];NSString *grantString = [NSString stringWithFormat:@"id=\\"%@\\"",ownerIdentifier];// 赋予被授权者读写权限putACL.grantFullControl = grantString;// 赋予被授权者读权限putACL.grantRead = grantString;// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketputACL.bucket = @"examplebucket-1250000000";[putACL setFinishBlock:^(id outputObject, NSError *error) {// 可以从 outputObject 中获取服务器返回的 header 信息NSDictionary * result = (NSDictionary *)outputObject;}];// 设置acl[[QCloudCOSXMLService defaultCOSXML] PutBucketACL:putACL];
let putBucketACLReq = QCloudPutBucketACLRequest.init();// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketputBucketACLReq.bucket = "examplebucket-1250000000";// 授予权限的账号 IDlet appTD = "100000000001";let ownerIdentifier = "qcs::cam::uin/\\(appTD):uin/\\(appTD)";let grantString = "id=\\"\\(ownerIdentifier)\\"";// 赋予被授权者写权限putBucketACLReq.grantWrite = grantString;// 赋予被授权者读权限putBucketACLReq.grantRead = grantString;// 赋予被授权者读写权限 grantFullControl == grantRead + grantWriteputBucketACLReq.grantFullControl = grantString;putBucketACLReq.finishBlock = {(result,error) inif let result = result {// 可以从 result 中获取服务器返回的 header 信息} else {print(error!)}}QCloudCOSXMLService.defaultCOSXML().putBucketACL(putBucketACLReq);
QCloudGetBucketACLRequest* getBucketACl = [QCloudGetBucketACLRequest new];// 存储桶名称,格式:BucketName-APPIDgetBucketACl.bucket = @"examplebucket-1250000000";[getBucketACl setFinishBlock:^(QCloudACLPolicy * _Nonnull result,NSError * _Nonnull error) {// 被授权者与权限的信息QCloudAccessControlList *acl = result.accessControlList;}];[[QCloudCOSXMLService defaultCOSXML] GetBucketACL:getBucketACl];
let getBucketACLReq = QCloudGetBucketACLRequest.init();// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketgetBucketACLReq.bucket = "examplebucket-1250000000";getBucketACLReq.setFinish { (result, error) inif let result = result {// ACL 授权信息let acl = result.accessControlList;} else {print(error!)}}QCloudCOSXMLService.defaultCOSXML().getBucketACL(getBucketACLReq)
QCloudPutObjectACLRequest* request = [QCloudPutObjectACLRequest new];// 对象键,是对象在 COS 上的完整路径,如果带目录的话,格式为 "video/xxx/movie.mp4"request.object = @"exampleobject";// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketrequest.bucket = @"examplebucket-1250000000";NSString *grantString = [NSString stringWithFormat:@"id=\\"%@\\"",@"100000000001"];// grantFullControl 等价于 grantRead + grantWrite// 赋予被授权者读写权限。request.grantFullControl = grantString;// 赋予被授权者读权限。request.grantRead = grantString;[request setFinishBlock:^(id outputObject, NSError *error) {// 可以从 outputObject 中获取 response 中 etag 或者自定义头部等信息NSDictionary* info = (NSDictionary *) outputObject;}];[[QCloudCOSXMLService defaultCOSXML] PutObjectACL:request];
let putObjectACl = QCloudPutObjectACLRequest.init();// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketputObjectACl.bucket = "examplebucket-1250000000";// 对象键,是对象在 COS 上的完整路径,如果带目录的话,格式为 "video/xxx/movie.mp4"putObjectACl.object = "exampleobject";let grantString = "id=\\"100000000001\\"";// grantFullControl 等价于 grantRead + grantWriteputObjectACl.grantFullControl = grantString;// 赋予被授权者读权限。putObjectACl.grantRead = grantString;putObjectACl.finishBlock = {(result,error)inif let result = result {// result 包含响应的 header 信息} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().putObjectACL(putObjectACl);
QCloudGetObjectACLRequest *request = [QCloudGetObjectACLRequest new];// 对象键,是对象在 COS 上的完整路径,如果带目录的话,格式为 "video/xxx/movie.mp4"request.object = @"exampleobject";// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketrequest.bucket = @"examplebucket-1250000000";__block QCloudACLPolicy* policy;[request setFinishBlock:^(QCloudACLPolicy * _Nonnull result,NSError * _Nonnull error) {policy = result;// result.accessControlList; 被授权者与权限的信息// result.owner; 持有者的信息}];[[QCloudCOSXMLService defaultCOSXML] GetObjectACL:request];
let getObjectACL = QCloudGetObjectACLRequest.init();// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketgetObjectACL.bucket = "examplebucket-1250000000";// 对象键,是对象在 COS 上的完整路径,如果带目录的话,格式为 "video/xxx/movie.mp4"getObjectACL.object = "exampleobject";getObjectACL.setFinish { (result, error) inif let result = result {// 对象授权信息let acl = result.accessControlList} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().getObjectACL(getObjectACL);
本页内容是否解决了您的问题?