GetBucketRequest.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using COSXML.Common;
  5. namespace COSXML.Model.Bucket
  6. {
  7. /// <summary>
  8. /// 获取 Bucket 中对象列表
  9. /// <see href="https://cloud.tencent.com/document/product/436/7734"/>
  10. /// </summary>
  11. public sealed class GetBucketRequest : BucketRequest
  12. {
  13. public GetBucketRequest(string bucket)
  14. : base(bucket)
  15. {
  16. this.method = CosRequestMethod.GET;
  17. this.queryParameters.Add("max-keys", 1000.ToString());
  18. }
  19. /// <summary>
  20. /// 前缀匹配,用来规定返回的文件前缀地址
  21. /// </summary>
  22. /// <param name="prefix"></param>
  23. public void SetPrefix(string prefix)
  24. {
  25. if (prefix != null)
  26. {
  27. SetQueryParameter("prefix", prefix);
  28. }
  29. }
  30. /// <summary>
  31. /// 定界符为一个符号,
  32. /// 如果有 Prefix,则将 Prefix 到 delimiter 之间的相同路径归为一类,定义为 Common Prefix,然后列出所有 Common Prefix。
  33. /// 如果没有 Prefix,则从路径起点开始
  34. /// </summary>
  35. /// <param name="delimiter"></param>
  36. public void SetDelimiter(string delimiter)
  37. {
  38. if (delimiter != null)
  39. {
  40. SetQueryParameter("delimiter", delimiter);
  41. }
  42. }
  43. /// <summary>
  44. /// 规定返回值的编码方式,可选值:url
  45. /// </summary>
  46. /// <param name="encodingType"></param>
  47. public void SetEncodingType(string encodingType)
  48. {
  49. if (encodingType != null)
  50. {
  51. SetQueryParameter("encoding-type", encodingType);
  52. }
  53. }
  54. /// <summary>
  55. /// 默认以 UTF-8 二进制顺序列出条目,所有列出条目从 marker 开始
  56. /// </summary>
  57. /// <param name="marker"></param>
  58. public void SetMarker(string marker)
  59. {
  60. if (marker != null)
  61. {
  62. SetQueryParameter("marker", marker);
  63. }
  64. }
  65. /// <summary>
  66. /// 单次返回最大的条目数量,默认 1000
  67. /// </summary>
  68. /// <param name="maxKeys"></param>
  69. public void SetMaxKeys(string maxKeys)
  70. {
  71. if (maxKeys != null)
  72. {
  73. SetQueryParameter("max-keys", maxKeys);
  74. }
  75. }
  76. }
  77. }