DeleteObjectsRequestSerializer.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright (C) Alibaba Cloud Computing
  3. * All rights reserved.
  4. *
  5. * 版权所有 (C)阿里云计算有限公司
  6. */
  7. using System.IO;
  8. using Aliyun.OSS.Model;
  9. using System.Collections.Generic;
  10. namespace Aliyun.OSS.Transform
  11. {
  12. internal class DeleteObjectsRequestSerializer : RequestSerializer<DeleteObjectsRequest, DeleteObjectsRequestModel>
  13. {
  14. public DeleteObjectsRequestSerializer(ISerializer<DeleteObjectsRequestModel, Stream> contentSerializer)
  15. : base(contentSerializer)
  16. {
  17. }
  18. public override Stream Serialize(DeleteObjectsRequest request)
  19. {
  20. var newKeys = new List<DeleteObjectsRequestModel.ObjectToDel>();
  21. foreach (var key in request.Keys)
  22. {
  23. newKeys.Add(new DeleteObjectsRequestModel.ObjectToDel { Key = key });
  24. }
  25. var model = new DeleteObjectsRequestModel
  26. {
  27. Quiet = request.Quiet,
  28. Keys = newKeys.ToArray()
  29. };
  30. return ContentSerializer.Serialize(model);
  31. }
  32. }
  33. }