DeleteObjectCommand.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (C) Alibaba Cloud Computing
  3. * All rights reserved.
  4. *
  5. * 版权所有 (C)阿里云计算有限公司
  6. */
  7. using System;
  8. using System.Collections.Generic;
  9. using Aliyun.OSS.Common.Communication;
  10. using Aliyun.OSS.Util;
  11. namespace Aliyun.OSS.Commands
  12. {
  13. internal class DeleteObjectCommand : OssCommand
  14. {
  15. private readonly string _bucketName;
  16. private readonly string _key;
  17. protected override HttpMethod Method
  18. {
  19. get { return HttpMethod.Delete; }
  20. }
  21. protected override string Bucket
  22. {
  23. get { return _bucketName; }
  24. }
  25. protected override string Key
  26. {
  27. get { return _key; }
  28. }
  29. protected override IDictionary<string, string> Parameters
  30. {
  31. get
  32. {
  33. return new Dictionary<string, string>()
  34. {
  35. {RequestParameters.ENCODING_TYPE, HttpUtils.UrlEncodingType }
  36. };
  37. }
  38. }
  39. private DeleteObjectCommand(IServiceClient client, Uri endpoint, ExecutionContext context,
  40. string bucketName, string key)
  41. : base(client, endpoint, context)
  42. {
  43. OssUtils.CheckBucketName(bucketName);
  44. OssUtils.CheckObjectKey(key);
  45. _bucketName = bucketName;
  46. _key = key;
  47. }
  48. public static DeleteObjectCommand Create(IServiceClient client, Uri endpoint, ExecutionContext context,
  49. string bucketName, string key)
  50. {
  51. return new DeleteObjectCommand(client, endpoint, context, bucketName, key);
  52. }
  53. }
  54. }