PutBucketACLRequest.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using COSXML.Common;
  5. using COSXML.Utils;
  6. using COSXML.Model.Tag;
  7. namespace COSXML.Model.Bucket
  8. {
  9. /// <summary>
  10. /// 设置 Bucket 的ACL
  11. /// <see href="https://cloud.tencent.com/document/product/436/7737"/>
  12. /// </summary>
  13. public sealed class PutBucketACLRequest : BucketRequest
  14. {
  15. public PutBucketACLRequest(string bucket)
  16. : base(bucket)
  17. {
  18. this.method = CosRequestMethod.PUT;
  19. this.queryParameters.Add("acl", null);
  20. }
  21. /// <summary>
  22. /// 定义 Object 的 acl 属性。有效值:private,public-read-write,public-read;默认值:private
  23. /// <see href="Common.CosACL"/>
  24. /// </summary>
  25. /// <param name="cosACL"></param>
  26. public void SetCosACL(string cosACL)
  27. {
  28. if (cosACL != null)
  29. {
  30. SetRequestHeader(CosRequestHeaderKey.X_COS_ACL, cosACL);
  31. }
  32. }
  33. /// <summary>
  34. /// 定义 Object 的 acl 属性。有效值:private,public-read-write,public-read;默认值:private
  35. /// <see href="Common.CosACL"/>
  36. /// </summary>
  37. /// <param name="cosACL"></param>
  38. public void SetCosACL(CosACL cosACL)
  39. {
  40. SetCosACL(EnumUtils.GetValue(cosACL));
  41. }
  42. /// <summary>
  43. /// 赋予被授权者读的权限
  44. /// <see href="Model.Tag.GrantAccount"/>
  45. /// </summary>
  46. /// <param name="grantAccount"></param>
  47. public void SetXCosGrantRead(GrantAccount grantAccount)
  48. {
  49. if (grantAccount != null)
  50. {
  51. SetRequestHeader(CosRequestHeaderKey.X_COS_GRANT_READ, grantAccount.GetGrantAccounts());
  52. }
  53. }
  54. /// <summary>
  55. /// 赋予被授权者写的权限
  56. /// <see href="Model.Tag.GrantAccount"/>
  57. /// </summary>
  58. /// <param name="grantAccount"></param>
  59. public void SetXCosGrantWrite(GrantAccount grantAccount)
  60. {
  61. if (grantAccount != null)
  62. {
  63. SetRequestHeader(CosRequestHeaderKey.X_COS_GRANT_WRITE, grantAccount.GetGrantAccounts());
  64. }
  65. }
  66. /// <summary>
  67. /// 赋予被授权者所有的权限
  68. /// <see href="Model.Tag.GrantAccount"/>
  69. /// </summary>
  70. /// <param name="grantAccount"></param>
  71. public void SetXCosReadWrite(GrantAccount grantAccount)
  72. {
  73. if (grantAccount != null)
  74. {
  75. SetRequestHeader(CosRequestHeaderKey.X_COS_GRANT_FULL_CONTROL, grantAccount.GetGrantAccounts());
  76. }
  77. }
  78. }
  79. }