GetObjectMetadataCommand.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. using Aliyun.OSS.Transform;
  11. namespace Aliyun.OSS.Commands
  12. {
  13. internal class GetObjectMetadataCommand : OssCommand<ObjectMetadata>
  14. {
  15. private readonly string _bucketName;
  16. private readonly string _key;
  17. protected override HttpMethod Method
  18. {
  19. get { return HttpMethod.Head; }
  20. }
  21. protected override string Bucket
  22. {
  23. get { return _bucketName; }
  24. }
  25. protected override string Key
  26. {
  27. get { return _key; }
  28. }
  29. private GetObjectMetadataCommand(IServiceClient client, Uri endpoint, ExecutionContext context,
  30. IDeserializer<ServiceResponse, ObjectMetadata> deserializer,
  31. string bucketName, string key)
  32. : base(client, endpoint, context, deserializer)
  33. {
  34. OssUtils.CheckBucketName(bucketName);
  35. OssUtils.CheckObjectKey(key);
  36. _bucketName = bucketName;
  37. _key = key;
  38. }
  39. public static GetObjectMetadataCommand Create(IServiceClient client, Uri endpoint, ExecutionContext context,
  40. string bucketName, string key)
  41. {
  42. return new GetObjectMetadataCommand(client, endpoint, context,
  43. DeserializerFactory.GetFactory().CreateGetObjectMetadataResultDeserializer(),
  44. bucketName, key);
  45. }
  46. }
  47. }