CompleteMultipartUploadRequestSerializer.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (C) Alibaba Cloud Computing
  3. * All rights reserved.
  4. *
  5. * 版权所有 (C)阿里云计算有限公司
  6. */
  7. using System.IO;
  8. using System.Collections.Generic;
  9. using Aliyun.OSS.Model;
  10. namespace Aliyun.OSS.Transform
  11. {
  12. internal class CompleteMultipartUploadRequestSerializer
  13. : RequestSerializer<CompleteMultipartUploadRequest, CompleteMultipartUploadRequestModel>
  14. {
  15. public CompleteMultipartUploadRequestSerializer(ISerializer<CompleteMultipartUploadRequestModel, Stream> contentSerializer)
  16. : base(contentSerializer)
  17. { }
  18. public override Stream Serialize(CompleteMultipartUploadRequest request)
  19. {
  20. var model = new CompleteMultipartUploadRequestModel();
  21. var modelParts = new List<CompleteMultipartUploadRequestModel.CompletePart>();
  22. foreach (var part in request.PartETags)
  23. {
  24. var modelPart = new CompleteMultipartUploadRequestModel.CompletePart
  25. {
  26. ETag = "\"" + part.ETag + "\"",
  27. PartNumber = part.PartNumber
  28. };
  29. modelParts.Add(modelPart);
  30. }
  31. model.Parts = modelParts.ToArray();
  32. return ContentSerializer.Serialize(model);
  33. }
  34. }
  35. }