DownloadObjectRequest.h 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 <alibabacloud/oss/Export.h>
  18. #include <alibabacloud/oss/OssRequest.h>
  19. #include <alibabacloud/oss/model/ObjectMetaData.h>
  20. namespace AlibabaCloud
  21. {
  22. namespace OSS
  23. {
  24. class ALIBABACLOUD_OSS_EXPORT DownloadObjectRequest : public OssResumableBaseRequest
  25. {
  26. public:
  27. DownloadObjectRequest(const std::string& bucket, const std::string& key,
  28. const std::string& filePath);
  29. DownloadObjectRequest(const std::string& bucket, const std::string& key,
  30. const std::string& filePath, const std::string& checkpointDir,
  31. const uint64_t partSize, const uint32_t threadNum);
  32. DownloadObjectRequest(const std::string& bucket, const std::string& key,
  33. const std::string& filePath, const std::string& checkpointDir);
  34. const std::string& FilePath() const { return filePath_; }
  35. const std::string& TempFilePath() const { return tempFilePath_; }
  36. DownloadObjectRequest(const std::string& bucket, const std::string& key,
  37. const std::wstring& filePath);
  38. DownloadObjectRequest(const std::string& bucket, const std::string& key,
  39. const std::wstring& filePath, const std::wstring& checkpointDir,
  40. const uint64_t partSize, const uint32_t threadNum);
  41. DownloadObjectRequest(const std::string& bucket, const std::string& key,
  42. const std::wstring& filePath, const std::wstring& checkpointDir);
  43. const std::wstring& FilePathW() const { return filePathW_; }
  44. const std::wstring& TempFilePathW() const { return tempFilePathW_; }
  45. std::shared_ptr<std::iostream> Content() { return content_; }
  46. bool RangeIsSet() const{ return rangeIsSet_; }
  47. int64_t RangeStart() const { return range_[0]; }
  48. int64_t RangeEnd() const { return range_[1]; }
  49. const std::string& ModifiedSinceConstraint() const { return modifiedSince_; }
  50. const std::string& UnmodifiedSinceConstraint() const { return unmodifiedSince_; }
  51. const std::vector<std::string>& MatchingETagsConstraint() const { return matchingETags_; }
  52. const std::vector<std::string>& NonmatchingETagsConstraint() const { return nonmatchingETags_;}
  53. const std::map<std::string, std::string>& ResponseHeaderParameters() const { return responseHeaderParameters_; }
  54. void setRange(int64_t start, int64_t end);
  55. void setModifiedSinceConstraint(const std::string& gmt);
  56. void setUnmodifiedSinceConstraint(const std::string& gmt);
  57. void setMatchingETagConstraints(const std::vector<std::string>& match);
  58. void setNonmatchingETagConstraints(const std::vector<std::string>& match);
  59. void addResponseHeaders(RequestResponseHeader header, const std::string& value);
  60. protected:
  61. virtual int validate() const;
  62. private:
  63. bool rangeIsSet_;
  64. int64_t range_[2];
  65. std::string modifiedSince_;
  66. std::string unmodifiedSince_;
  67. std::vector<std::string> matchingETags_;
  68. std::vector<std::string> nonmatchingETags_;
  69. std::string filePath_;
  70. std::string tempFilePath_;
  71. std::shared_ptr<std::iostream> content_;
  72. std::map<std::string, std::string> responseHeaderParameters_;
  73. std::wstring filePathW_;
  74. std::wstring tempFilePathW_;
  75. };
  76. }
  77. }