API | Operation | Description |
Setting a bucket ACL | Sets an ACL for a bucket | |
Querying a bucket ACL | Queries the ACL of a bucket |
API | Operation | Description |
Setting an object ACL | Sets an ACL for an object in a bucket | |
Querying an object ACL | Queries the ACL of an object |
QCloudPutBucketACLRequest* putACL = [QCloudPutBucketACLRequest new];// ID of the authorized accountNSString* uin = @"100000000001";NSString *ownerIdentifier = [NSString stringWithFormat:@"qcs::cam::uin/%@:uin/%@", uin,uin];NSString *grantString = [NSString stringWithFormat:@"id=\\"%@\\"",ownerIdentifier];// Grant read and write permissionputACL.grantFullControl = grantString;// Grant read permissionputACL.grantRead = grantString;// Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketputACL.bucket = @"examplebucket-1250000000";[putACL setFinishBlock:^(id outputObject, NSError *error) {// You can get the headers returned by the server from outputObjectNSDictionary * result = (NSDictionary *)outputObject;}];// Set an ACL[[QCloudCOSXMLService defaultCOSXML] PutBucketACL:putACL];
let putBucketACLReq = QCloudPutBucketACLRequest.init();// Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketputBucketACLReq.bucket = "examplebucket-1250000000";// ID of the authorized accountlet appTD = "100000000001";let ownerIdentifier = "qcs::cam::uin/\\(appTD):uin/\\(appTD)";let grantString = "id=\\"\\(ownerIdentifier)\\"";// Grants write permissionputBucketACLReq.grantWrite = grantString;// Grant read permissionputBucketACLReq.grantRead = grantString;// Grant full control (read and write permission) grantFullControl == grantRead + grantWriteputBucketACLReq.grantFullControl = grantString;putBucketACLReq.finishBlock = {(result,error) inif let result = result {// You can get the header information returned by the server from `result`} else {print(error!)}}QCloudCOSXMLService.defaultCOSXML().putBucketACL(putBucketACLReq);
QCloudGetBucketACLRequest* getBucketACl = [QCloudGetBucketACLRequest new];// Bucket name in the format: `BucketName-APPID`getBucketACl.bucket = @"examplebucket-1250000000";[getBucketACl setFinishBlock:^(QCloudACLPolicy * _Nonnull result,NSError * _Nonnull error) {// The authorized account and granted permissionsQCloudAccessControlList *acl = result.accessControlList;}];[[QCloudCOSXMLService defaultCOSXML] GetBucketACL:getBucketACl];
let getBucketACLReq = QCloudGetBucketACLRequest.init();// Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketgetBucketACLReq.bucket = "examplebucket-1250000000";getBucketACLReq.setFinish { (result, error) inif let result = result {// ACL authorization informationlet acl = result.accessControlList;} else {print(error!)}}QCloudCOSXMLService.defaultCOSXML().getBucketACL(getBucketACLReq)
QCloudPutObjectACLRequest* request = [QCloudPutObjectACLRequest new];// Object key, i.e. the full path of a COS object. If the object is in a directory, the path should be "video/xxx/movie.mp4"request.object = @"exampleobject";// Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketrequest.bucket = @"examplebucket-1250000000";NSString *grantString = [NSString stringWithFormat:@"id=\\"%@\\"",@"100000000001"];// grantFullControl grants both read and write permission// Grant read and write permissionrequest.grantFullControl = grantString;// Grant read permissionrequest.grantRead = grantString;[request setFinishBlock:^(id outputObject, NSError *error) {// outputObject contains information such as the ETag or custom headers in the response.NSDictionary* info = (NSDictionary *) outputObject;}];[[QCloudCOSXMLService defaultCOSXML] PutObjectACL:request];
let putObjectACl = QCloudPutObjectACLRequest.init();// Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketputObjectACl.bucket = "examplebucket-1250000000";// Object key, i.e. the full path of a COS object. If the object is in a directory, the path should be "video/xxx/movie.mp4"putObjectACl.object = "exampleobject";let grantString = "id=\\"100000000001\\"";// grantFullControl grants both read and write permissionputObjectACl.grantFullControl = grantString;// Grant read permissionputObjectACl.grantRead = grantString;putObjectACl.finishBlock = {(result,error)inif let result = result {// "result" contains response headers.} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().putObjectACL(putObjectACl);
QCloudGetObjectACLRequest *request = [QCloudGetObjectACLRequest new];// Object key, i.e. the full path of a COS object. If the object is in a directory, the path should be "video/xxx/movie.mp4"request.object = @"exampleobject";// Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketrequest.bucket = @"examplebucket-1250000000";__block QCloudACLPolicy* policy;[request setFinishBlock:^(QCloudACLPolicy * _Nonnull result,NSError * _Nonnull error) {policy = result;// result.accessControlList; the authorized user and granted permissions// result.owner; the object owner}];[[QCloudCOSXMLService defaultCOSXML] GetObjectACL:request];
let getObjectACL = QCloudGetObjectACLRequest.init();// Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketgetObjectACL.bucket = "examplebucket-1250000000";// Object key, i.e. the full path of a COS object. If the object is in a directory, the path should be "video/xxx/movie.mp4"getObjectACL.object = "exampleobject";getObjectACL.setFinish { (result, error) inif let result = result {// Object authorization informationlet acl = result.accessControlList} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().getObjectACL(getObjectACL);
Apakah halaman ini membantu?