InitMultipartUploadRequest.cs 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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.Object
  8. {
  9. /// <summary>
  10. /// 实现初始化分片上传,成功执行此请求以后会返回 UploadId 用于后续的 Upload Part 请求
  11. /// <see href="https://cloud.tencent.com/document/product/436/7746"/>
  12. /// </summary>
  13. public sealed class InitMultipartUploadRequest : ObjectRequest
  14. {
  15. public InitMultipartUploadRequest(string bucket, string key)
  16. : base(bucket, key)
  17. {
  18. this.method = CosRequestMethod.POST;
  19. this.queryParameters.Add("uploads", null);
  20. }
  21. /// <summary>
  22. /// 设置 Object 的存储级别
  23. /// <see href="Common.CosStorageClass"/>
  24. /// </summary>
  25. /// <param name="cosStorageClass"></param>
  26. public void SetCosStorageClass(string cosStorageClass)
  27. {
  28. if (cosStorageClass != null)
  29. {
  30. SetRequestHeader(CosRequestHeaderKey.X_COS_STORAGE_CLASS, cosStorageClass);
  31. }
  32. }
  33. /// <summary>
  34. /// Object 的 ACL 属性,有效值:private,public-read-write,public-read,
  35. /// default;默认值:default(继承 Bucket 权限)
  36. /// 当前访问策略条目限制为 1000 条,
  37. /// 如果您不需要进行 Object ACL 控制,请填 default 或者此项不进行设置,
  38. /// 默认继承 Bucket 权限
  39. /// <see href="Common.CosACL"/>
  40. /// </summary>
  41. /// <param name="cosACL"></param>
  42. public void SetCosACL(string cosACL)
  43. {
  44. if (cosACL != null)
  45. {
  46. SetRequestHeader(CosRequestHeaderKey.X_COS_ACL, cosACL);
  47. }
  48. }
  49. /// Object 的 ACL 属性,有效值:private,public-read-write,public-read,
  50. /// default;默认值:default(继承 Bucket 权限)
  51. /// 当前访问策略条目限制为 1000 条,
  52. /// 如果您不需要进行 Object ACL 控制,请填 default 或者此项不进行设置,
  53. /// 默认继承 Bucket 权限
  54. /// <see href="Common.CosACL"/>
  55. public void SetCosACL(CosACL cosACL)
  56. {
  57. SetCosACL(EnumUtils.GetValue(cosACL));
  58. }
  59. /// <summary>
  60. /// 赋予被授权者读的权限
  61. /// <see href="Model.Tag.GrantAccount"/>
  62. /// </summary>
  63. /// <param name="grantAccount"></param>
  64. public void SetXCosGrantRead(GrantAccount grantAccount)
  65. {
  66. if (grantAccount != null)
  67. {
  68. SetRequestHeader(CosRequestHeaderKey.X_COS_GRANT_READ, grantAccount.GetGrantAccounts());
  69. }
  70. }
  71. /// <summary>
  72. /// 赋予被授权者读写的权限
  73. /// <see href="Model.Tag.GrantAccount"/>
  74. /// </summary>
  75. /// <param name="grantAccount"></param>
  76. public void SetXCosReadWrite(GrantAccount grantAccount)
  77. {
  78. if (grantAccount != null)
  79. {
  80. SetRequestHeader(CosRequestHeaderKey.X_COS_GRANT_FULL_CONTROL, grantAccount.GetGrantAccounts());
  81. }
  82. }
  83. }
  84. }