AbortMultipartUploadRequest.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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/7740"/>
  11. /// </summary>
  12. public sealed class AbortMultipartUploadRequest : ObjectRequest
  13. {
  14. /// <summary>
  15. /// 分片块的UploadId,使用 Initiate Multipart Upload 接口初始化分片上传时会得到一个 uploadId,该 ID 不但唯一标识这一分块数据,也标识了这分块数据在整个文件内的相对位置
  16. /// </summary>
  17. private string uploadId;
  18. public AbortMultipartUploadRequest(string bucket, string key, string uploadId)
  19. : base(bucket, key)
  20. {
  21. this.uploadId = uploadId;
  22. this.method = CosRequestMethod.DELETE;
  23. }
  24. public override void CheckParameters()
  25. {
  26. if (requestUrlWithSign != null)
  27. {
  28. return;
  29. }
  30. base.CheckParameters();
  31. if (uploadId == null)
  32. {
  33. throw new CosClientException((int)CosClientError.InvalidArgument, "uploadId is null");
  34. }
  35. }
  36. protected override void InternalUpdateQueryParameters()
  37. {
  38. try
  39. {
  40. this.queryParameters.Add("uploadId", uploadId);
  41. }
  42. catch (ArgumentException)
  43. {
  44. this.queryParameters["uploadId"] = uploadId;
  45. }
  46. }
  47. }
  48. }