QCloudPutObjectACLRequest.h 6.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. //
  2. // PutObjectACL.h
  3. // PutObjectACL
  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. 设置 COS 对象的访问权限信息(Access Control List, ACL)的方法.
  30. ACL权限包括读、写、读写权限. COS 对象的 ACL 可以通过 header头部:"x-cos-acl","x-cos-grant-read","x-cos-grant-write", "x-cos-grant-full-control" 传入 ACL 信息,或者通过 Body 以 XML 格式传入 ACL 信息.这两种方式只 能选择其中一种,否则引起冲突. 传入新的 ACL 将覆盖原有 ACL信息.ACL策略数上限1000,建议用户不要每个上传文件都设置 ACL.
  31. 关于设置 COS 对象的ACL接口的具体描述,请查看https://cloud.tencent.com/document/product/436/7748.
  32. cos iOS SDK 中设置 COS 对象的 ACL 的方法具体步骤如下:
  33. 1. 实例化 QCloudPutObjectACLRequest,填入存储桶名,和一些额外需要的参数,如授权的具体信息等。
  34. 2. 调用 QCloudCOSXMLService 对象中的方法发出请求。
  35. 3. 从回调的 finishBlock 中获取设置的完成情况,若 error 为空,则设置成功。
  36. 示例:
  37. @code
  38. QCloudPutObjectACLRequest* request = [QCloudPutObjectACLRequest new];
  39. request.object = @"需要设置 ACL 的对象名";
  40. request.bucket = @"testBucket-123456789";
  41. NSString *ownerIdentifier = [NSString stringWithFormat:@"qcs::cam::uin/%@:uin/%@",self.appID, self.appID];
  42. NSString *grantString = [NSString stringWithFormat:@"id=\"%@\"",ownerIdentifier];
  43. request.grantFullControl = grantString;
  44. __block NSError* localError;
  45. [request setFinishBlock:^(id outputObject, NSError *error) {
  46. localError = error;
  47. }];
  48. [[QCloudCOSXMLService defaultCOSXML] PutObjectACL:request];
  49. @endcode
  50. */
  51. @interface QCloudPutObjectACLRequest : QCloudBizHTTPRequest
  52. /**
  53. object名
  54. */
  55. @property (strong, nonatomic) NSString *object;
  56. /**
  57. 定义 Object 的 ACL 属性。有效值:private,public-read-write,public-read;默认值:private
  58. */
  59. @property (strong, nonatomic) NSString *accessControlList;
  60. /**
  61. 赋予被授权者读的权限。格式:id=" ",id=" ";
  62. 当需要给子账户授权时,id="qcs::cam::uin/<OwnerUin>:uin/<SubUin>",
  63. 当需要给根账户授权时,id="qcs::cam::uin/<OwnerUin>:uin/<OwnerUin>"
  64. */
  65. @property (strong, nonatomic) NSString *grantRead;
  66. /**
  67. 赋予被授权者写的权限。格式:id=" ",id=" ";
  68. 当需要给子账户授权时,id="qcs::cam::uin/<OwnerUin>:uin/<SubUin>",
  69. 当需要给根账户授权时,id="qcs::cam::uin/<OwnerUin>:uin/<OwnerUin>"
  70. */
  71. @property (strong, nonatomic) NSString *grantWrite;
  72. /**
  73. 赋予被授权者读写权限。格式: id=" ",id=" " ;
  74. 当需要给子账户授权时,id="qcs::cam::uin/<OwnerUin>:uin/<SubUin>",
  75. 当需要给根账户授权时,id="qcs::cam::uin/<OwnerUin>:uin/<OwnerUin>"
  76. */
  77. @property (strong, nonatomic) NSString *grantFullControl;
  78. /**
  79. 存储桶名
  80. */
  81. @property (strong, nonatomic) NSString *bucket;
  82. @end
  83. NS_ASSUME_NONNULL_END