HeadObjectCommand.cs 1.4 KB

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