OssRequest.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /*
  2. * Copyright 2009-2017 Alibaba Cloud All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #pragma once
  17. #include <string>
  18. #include <alibabacloud/oss/ServiceRequest.h>
  19. namespace AlibabaCloud
  20. {
  21. namespace OSS
  22. {
  23. class OssClientImpl;
  24. class OssEncryptionClient;
  25. class ALIBABACLOUD_OSS_EXPORT OssRequest : public ServiceRequest
  26. {
  27. public:
  28. OssRequest();
  29. virtual ~ OssRequest() = default;
  30. virtual HeaderCollection Headers() const;
  31. virtual ParameterCollection Parameters() const;
  32. virtual std::shared_ptr<std::iostream> Body() const;
  33. protected:
  34. OssRequest(const std::string& bucket, const std::string& key);
  35. friend class OssClientImpl;
  36. friend class OssEncryptionClient;
  37. virtual int validate() const;
  38. const char *validateMessage(int code) const;
  39. virtual std::string payload() const;
  40. virtual HeaderCollection specialHeaders() const;
  41. virtual ParameterCollection specialParameters() const;
  42. const std::string& bucket() const;
  43. const std::string& key() const;
  44. protected:
  45. std::string bucket_;
  46. std::string key_;
  47. };
  48. class ALIBABACLOUD_OSS_EXPORT OssBucketRequest : public OssRequest
  49. {
  50. public:
  51. OssBucketRequest(const std::string& bucket):
  52. OssRequest(bucket, "")
  53. {}
  54. void setBucket(const std::string& bucket);
  55. const std::string& Bucket() const;
  56. protected:
  57. virtual int validate() const;
  58. };
  59. class ALIBABACLOUD_OSS_EXPORT OssObjectRequest : public OssRequest
  60. {
  61. public:
  62. OssObjectRequest(const std::string& bucket, const std::string& key) :
  63. OssRequest(bucket, key),
  64. requestPayer_(AlibabaCloud::OSS::RequestPayer::NotSet),
  65. versionId_()
  66. {}
  67. void setBucket(const std::string& bucket);
  68. const std::string& Bucket() const;
  69. void setKey(const std::string& key);
  70. const std::string& Key() const;
  71. void setRequestPayer(AlibabaCloud::OSS::RequestPayer value);
  72. AlibabaCloud::OSS::RequestPayer RequestPayer() const;
  73. void setVersionId(const std::string& versionId);
  74. const std::string& VersionId() const;
  75. protected:
  76. virtual int validate() const;
  77. virtual HeaderCollection specialHeaders() const;
  78. virtual ParameterCollection specialParameters() const;
  79. AlibabaCloud::OSS::RequestPayer requestPayer_;
  80. std::string versionId_;
  81. };
  82. class ALIBABACLOUD_OSS_EXPORT OssResumableBaseRequest : public OssRequest
  83. {
  84. public:
  85. OssResumableBaseRequest(const std::string& bucket, const std::string& key,
  86. const std::string& checkpointDir, const uint64_t partSize, const uint32_t threadNum) :
  87. OssRequest(bucket, key),
  88. partSize_(partSize),
  89. checkpointDir_(checkpointDir),
  90. requestPayer_(AlibabaCloud::OSS::RequestPayer::NotSet),
  91. trafficLimit_(0),
  92. versionId_()
  93. {
  94. threadNum_ = threadNum == 0 ? 1 : threadNum;
  95. }
  96. OssResumableBaseRequest(const std::string& bucket, const std::string& key,
  97. const std::wstring& checkpointDir, const uint64_t partSize, const uint32_t threadNum) :
  98. OssRequest(bucket, key),
  99. partSize_(partSize),
  100. checkpointDirW_(checkpointDir),
  101. requestPayer_(AlibabaCloud::OSS::RequestPayer::NotSet),
  102. trafficLimit_(0),
  103. versionId_()
  104. {
  105. threadNum_ = threadNum == 0 ? 1 : threadNum;
  106. }
  107. void setBucket(const std::string& bucket);
  108. const std::string& Bucket() const;
  109. void setKey(const std::string& key);
  110. const std::string& Key() const;
  111. void setPartSize(uint64_t partSize);
  112. uint64_t PartSize() const;
  113. void setObjectSize(uint64_t objectSize);
  114. uint64_t ObjectSize() const;
  115. void setThreadNum(uint32_t threadNum);
  116. uint32_t ThreadNum() const;
  117. void setCheckpointDir(const std::string& checkpointDir);
  118. const std::string& CheckpointDir() const;
  119. void setCheckpointDir(const std::wstring& checkpointDir);
  120. const std::wstring& CheckpointDirW() const;
  121. bool hasCheckpointDir() const;
  122. void setObjectMtime(const std::string& mtime);
  123. const std::string& ObjectMtime() const;
  124. void setRequestPayer(RequestPayer value);
  125. AlibabaCloud::OSS::RequestPayer RequestPayer() const;
  126. void setTrafficLimit(uint64_t value);
  127. uint64_t TrafficLimit() const;
  128. void setVersionId(const std::string& versionId);
  129. const std::string& VersionId() const;
  130. protected:
  131. friend class OssClientImpl;
  132. friend class OssEncryptionClient;
  133. virtual int validate() const;
  134. const char *validateMessage(int code) const;
  135. protected:
  136. uint64_t partSize_;
  137. uint64_t objectSize_;
  138. uint32_t threadNum_;
  139. std::string checkpointDir_;
  140. std::wstring checkpointDirW_;
  141. std::string mtime_;
  142. AlibabaCloud::OSS::RequestPayer requestPayer_;
  143. uint64_t trafficLimit_;
  144. std::string versionId_;
  145. };
  146. class ALIBABACLOUD_OSS_EXPORT LiveChannelRequest : public OssRequest
  147. {
  148. public:
  149. LiveChannelRequest(const std::string &bucket, const std::string &channelName) :
  150. OssRequest(bucket, channelName),
  151. channelName_(channelName)
  152. {}
  153. void setBucket(const std::string &bucket);
  154. const std::string& Bucket() const;
  155. void setChannelName(const std::string &channelName);
  156. const std::string& ChannelName() const;
  157. protected:
  158. virtual int validate() const;
  159. protected:
  160. std::string channelName_;
  161. };
  162. }
  163. }