SetBucketAclCommand.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 SetBucketAclCommand : OssCommand
  14. {
  15. private readonly string _bucketName;
  16. private readonly SetBucketAclRequest _request;
  17. protected override HttpMethod Method
  18. {
  19. get { return HttpMethod.Put; }
  20. }
  21. protected override string Bucket
  22. {
  23. get { return _bucketName; }
  24. }
  25. private SetBucketAclCommand(IServiceClient client, Uri endpoint, ExecutionContext context,
  26. string bucketName, SetBucketAclRequest request)
  27. : base(client, endpoint, context)
  28. {
  29. OssUtils.CheckBucketName(bucketName);
  30. _bucketName = bucketName;
  31. _request = request;
  32. }
  33. public static SetBucketAclCommand Create(IServiceClient client, Uri endpoint,
  34. ExecutionContext context,
  35. string bucketName, SetBucketAclRequest request)
  36. {
  37. return new SetBucketAclCommand(client, endpoint, context, bucketName, request);
  38. }
  39. protected override IDictionary<string, string> Headers
  40. {
  41. get
  42. {
  43. return new Dictionary<string, string>()
  44. {
  45. { OssHeaders.OssCannedAcl, EnumUtils.GetStringValue(_request.ACL) }
  46. };
  47. }
  48. }
  49. protected override IDictionary<string, string> Parameters
  50. {
  51. get
  52. {
  53. return new Dictionary<string, string>()
  54. {
  55. { RequestParameters.SUBRESOURCE_ACL, null }
  56. };
  57. }
  58. }
  59. }
  60. }