QCloudPutBucketACLRequest.h 6.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //
  2. // PutBucketACL.h
  3. // PutBucketACL
  4. //
  5. // Created by tencent
  6. // Copyright (c) 2015年 tencent. All rights reserved.
  7. //
  8. // ██████╗ ██████╗██╗ ██████╗ ██╗ ██╗██████╗ ████████╗███████╗██████╗ ███╗ ███╗██╗███╗ ██╗ █████╗ ██╗ ██╗ █████╗ ██████╗
  9. // ██╔═══██╗██╔════╝██║ ██╔═══██╗██║ ██║██╔══██╗ ╚══██╔══╝██╔════╝██╔══██╗████╗ ████║██║████╗ ██║██╔══██╗██║ ██║ ██╔══██╗██╔══██╗
  10. // ██║ ██║██║ ██║ ██║ ██║██║ ██║██║ ██║ ██║ █████╗ ██████╔╝██╔████╔██║██║██╔██╗ ██║███████║██║ ██║ ███████║██████╔╝
  11. // ██║▄▄ ██║██║ ██║ ██║ ██║██║ ██║██║ ██║ ██║ ██╔══╝ ██╔══██╗██║╚██╔╝██║██║██║╚██╗██║██╔══██║██║ ██║ ██╔══██║██╔══██╗
  12. // ╚██████╔╝╚██████╗███████╗╚██████╔╝╚██████╔╝██████╔╝ ██║ ███████╗██║ ██║██║ ╚═╝ ██║██║██║ ╚████║██║ ██║███████╗ ███████╗██║ ██║██████╔╝
  13. // ╚══▀▀═╝ ╚═════╝╚══════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝╚══════╝ ╚══════╝╚═╝ ╚═╝╚═════╝
  14. //
  15. //
  16. // _ __ _ _
  17. // (_) / _| | | | |
  18. // ___ ___ _ ____ ___ ___ ___ | |_ ___ _ __ __| | _____ _____| | ___ _ __ ___ _ __ ___
  19. // / __|/ _ \ '__\ \ / / |/ __/ _ \ | _/ _ \| '__| / _` |/ _ \ \ / / _ \ |/ _ \| '_ \ / _ \ '__/ __|
  20. // \__ \ __/ | \ V /| | (_| __/ | || (_) | | | (_| | __/\ V / __/ | (_) | |_) | __/ | \__
  21. // |___/\___|_| \_/ |_|\___\___| |_| \___/|_| \__,_|\___| \_/ \___|_|\___/| .__/ \___|_| |___/
  22. // ______ ______ ______ ______ ______ ______ ______ ______ | |
  23. // |______|______|______|______|______|______|______|______| |_|
  24. //
  25. #import <Foundation/Foundation.h>
  26. #import <QCloudCore/QCloudCore.h>
  27. NS_ASSUME_NONNULL_BEGIN
  28. /**
  29. 设置存储桶(Bucket) 的访问权限(Access Control List, ACL)的方法.
  30. ACL 权限包括读、写、读写权限. 写入 Bucket 的 ACL 可以通过 header头部:"x-cos-acl","x-cos-grant-read","x-cos-grant-write", "x-cos-grant-full-control" 传入 ACL 信息,或者通过 Body 以 XML 格式传入 ACL 信息.这两种方式只 能选择其中一种,否则引起冲突. 传入新的 ACL 将覆盖原有 ACL信息. 私有 Bucket 可以下可以给某个文件夹设置成公有,那么该文件夹下的文件都是公有;但是把文件夹设置成私有后,在该文件夹下的文件设置 的公有属性,不会生效.
  31. 关于设置 Bucket 的ACL接口的具体描述,请查看 https://cloud.tencent.com/document/product/436/7737.
  32. cos iOS SDK 中设置 Bucket 的ACL的方法具体步骤如下:
  33. 1. 实例化 QCloudPutBucketACLRequest,填入需要设置的存储桶,然后根据设置值的权限类型分别填入不同的参数。
  34. 2. 调用 QCloudCOSXMLService 对象中的 PutBucketACL 方法发出请求。
  35. 3. 从回调的 finishBlock 中的获取设置是否成功,并做设置成功后的一些额外动作。
  36. 示例:
  37. @code
  38. QCloudPutBucketACLRequest* putACL = [QCloudPutBucketACLRequest new];
  39. NSString* appID = kAppID;
  40. NSString *ownerIdentifier = [NSString stringWithFormat:@"qcs::cam::uin/%@:uin/%@", appID, appID];
  41. NSString *grantString = [NSString stringWithFormat:@"id=\"%@\"",ownerIdentifier];
  42. putACL.accessControlList = @"private";
  43. putACL.grantFullControl = grantString;
  44. putACL.bucket = bucketName; //存储桶名称(cos v5 的 bucket格式为:xxx-appid, 如 test-1253960454)
  45. [putACL setFinishBlock:^(id outputObject, NSError *error) {
  46. //additional actions after finishing
  47. }];
  48. [[QCloudCOSXMLService defaultCOSXML] PutBucketACL:putACL];
  49. @endcode
  50. */
  51. @interface QCloudPutBucketACLRequest : QCloudBizHTTPRequest
  52. /**
  53. 定义 Object 的 ACL 属性。有效值:private,public-read-write,public-read;默认值:private
  54. */
  55. @property (strong, nonatomic) NSString *accessControlList;
  56. /**
  57. 赋予被授权者读的权限。格式:x-cos-grant-read: id=" ",id=" ";
  58. 当需要给子账户授权时,id="qcs::cam::uin/<OwnerUin>:uin/<SubUin>",
  59. 当需要给根账户授权时,id="qcs::cam::uin/<OwnerUin>:uin/<OwnerUin>"
  60. 其中,<OwnerUin>为根账户的uin,而<SubUin>为子账户的uin,使用时替换
  61. */
  62. @property (strong, nonatomic) NSString *grantRead;
  63. /**
  64. 赋予被授权者写的权限。格式:x-cos-grant-write: id=" ",id=" ";
  65. 当需要给子账户授权时,id="qcs::cam::uin/<OwnerUin>:uin/<SubUin>",
  66. 当需要给根账户授权时,id="qcs::cam::uin/<OwnerUin>:uin/<OwnerUin>"
  67. 其中,<OwnerUin>为根账户的uin,而<SubUin>为子账户的uin,使用时替换
  68. */
  69. @property (strong, nonatomic) NSString *grantWrite;
  70. /**
  71. 赋予被授权者读写权限。格式: id=" ",id=" " ;
  72. 当需要给子账户授权时,id="qcs::cam::uin/<OwnerUin>:uin/<SubUin>",
  73. 当需要给根账户授权时,id="qcs::cam::uin/<OwnerUin>:uin/<OwnerUin>"
  74. 其中,<OwnerUin>为根账户的uin,而<SubUin>为子账户的uin,使用时替换
  75. */
  76. @property (strong, nonatomic) NSString *grantFullControl;
  77. /**
  78. 存储桶名
  79. */
  80. @property (strong, nonatomic) NSString *bucket;
  81. @end
  82. NS_ASSUME_NONNULL_END