ListPartsRequest.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using COSXML.Common;
  5. using COSXML.CosException;
  6. namespace COSXML.Model.Object
  7. {
  8. /// <summary>
  9. /// 查询特定分块上传中的已上传的块
  10. /// <see href="https://cloud.tencent.com/document/product/436/7747"/>
  11. /// </summary>
  12. public sealed class ListPartsRequest : ObjectRequest
  13. {
  14. /// <summary>
  15. /// 标识本次分块上传的 ID
  16. /// </summary>
  17. private string uploadId;
  18. public ListPartsRequest(string bucket, string key, string uploadId)
  19. : base(bucket, key)
  20. {
  21. this.method = CosRequestMethod.GET;
  22. this.uploadId = uploadId;
  23. }
  24. /// <summary>
  25. /// 单次返回最大的条目数量,默认 1000
  26. /// </summary>
  27. /// <param name="maxParts"></param>
  28. public void SetMaxParts(int maxParts)
  29. {
  30. SetQueryParameter(CosRequestHeaderKey.MAX_PARTS, maxParts.ToString());
  31. }
  32. /// <summary>
  33. /// 默认以 UTF-8 二进制顺序列出条目,所有列出条目从 marker 开始
  34. /// </summary>
  35. /// <param name="partNumberMarker"></param>
  36. public void SetPartNumberMarker(int partNumberMarker)
  37. {
  38. SetQueryParameter(CosRequestHeaderKey.PART_NUMBER_MARKER, partNumberMarker.ToString());
  39. }
  40. /// <summary>
  41. /// 规定返回值的编码方式
  42. /// </summary>
  43. /// <param name="encodingType"></param>
  44. public void SetEncodingType(string encodingType)
  45. {
  46. SetQueryParameter(CosRequestHeaderKey.ENCODING_TYPE, encodingType);
  47. }
  48. public override void CheckParameters()
  49. {
  50. if (requestUrlWithSign != null)
  51. {
  52. return;
  53. }
  54. base.CheckParameters();
  55. if (uploadId == null)
  56. {
  57. throw new CosClientException((int)CosClientError.InvalidArgument, "uploadId = null");
  58. }
  59. }
  60. protected override void InternalUpdateQueryParameters()
  61. {
  62. try
  63. {
  64. queryParameters.Add("uploadId", uploadId);
  65. }
  66. catch (ArgumentException)
  67. {
  68. queryParameters["uploadId"] = uploadId;
  69. }
  70. }
  71. }
  72. }