ListMultipartUploadsResponseDeserializer.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (C) Alibaba Cloud Computing
  3. * All rights reserved.
  4. *
  5. * 版权所有 (C)阿里云计算有限公司
  6. */
  7. using System.IO;
  8. using Aliyun.OSS.Common.Communication;
  9. using Aliyun.OSS.Model;
  10. using Aliyun.OSS.Util;
  11. namespace Aliyun.OSS.Transform
  12. {
  13. internal class ListMultipartUploadsResponseDeserializer : ResponseDeserializer<MultipartUploadListing, ListMultipartUploadsResult>
  14. {
  15. public ListMultipartUploadsResponseDeserializer(IDeserializer<Stream, ListMultipartUploadsResult> contentDeserializer)
  16. : base(contentDeserializer)
  17. { }
  18. public override MultipartUploadListing Deserialize(ServiceResponse xmlStream)
  19. {
  20. var listMultipartUploadsResult = ContentDeserializer.Deserialize(xmlStream.Content);
  21. string encodeType = listMultipartUploadsResult.EncodingType == null ?
  22. string.Empty : listMultipartUploadsResult.EncodingType.ToLowerInvariant();
  23. var uploadsList = new MultipartUploadListing(listMultipartUploadsResult.Bucket)
  24. {
  25. BucketName = listMultipartUploadsResult.Bucket,
  26. Delimiter = Decode(listMultipartUploadsResult.Delimiter, encodeType),
  27. IsTruncated = listMultipartUploadsResult.IsTruncated,
  28. KeyMarker = Decode(listMultipartUploadsResult.KeyMarker, encodeType),
  29. MaxUploads = listMultipartUploadsResult.MaxUploads,
  30. NextKeyMarker = Decode(listMultipartUploadsResult.NextKeyMarker, encodeType),
  31. NextUploadIdMarker = listMultipartUploadsResult.NextUploadIdMarker,
  32. Prefix = Decode(listMultipartUploadsResult.Prefix, encodeType),
  33. UploadIdMarker = listMultipartUploadsResult.UploadIdMarker
  34. };
  35. if (listMultipartUploadsResult.CommonPrefix != null)
  36. {
  37. if (listMultipartUploadsResult.CommonPrefix.Prefixs != null)
  38. {
  39. foreach (var prefix in listMultipartUploadsResult.CommonPrefix.Prefixs)
  40. {
  41. uploadsList.AddCommonPrefix(Decode(prefix, encodeType));
  42. }
  43. }
  44. }
  45. if (listMultipartUploadsResult.Uploads != null)
  46. {
  47. foreach (var uploadResult in listMultipartUploadsResult.Uploads)
  48. {
  49. var upload = new MultipartUpload
  50. {
  51. Initiated = uploadResult.Initiated,
  52. Key = Decode(uploadResult.Key, encodeType),
  53. UploadId = uploadResult.UploadId,
  54. StorageClass = uploadResult.StorageClass
  55. };
  56. uploadsList.AddMultipartUpload(upload);
  57. }
  58. }
  59. return uploadsList;
  60. }
  61. }
  62. }