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