AWS SDK for C++

AWS SDK for C++ Version 1.11.867

Loading...
Searching...
No Matches
DownloadRequestImpl.h
1
5#pragma once
6
7#include <aws/core/Core_EXPORTS.h>
8#include <aws/s3-transfer/DownloadRequest.h>
9#include <aws/core/client/AWSError.h>
10#include <aws/s3/S3Errors.h>
11#include <aws/s3/model/GetObjectRequest.h>
12#include <memory>
13
14namespace Aws {
15namespace S3 {
16namespace Transfer {
17
18struct DownloadTransferState;
19
20namespace Internal {
21
27class AWS_CORE_LOCAL DownloadRequestImpl {
28 public:
30 Aws::String key,
31 Aws::Vector<std::shared_ptr<DownloadProgressListener>> transferListeners);
32 virtual ~DownloadRequestImpl() = default;
33
38
39 // Empty when the request is usable; otherwise the validation error.
40 virtual OptionalError Validate() const { return OptionalError(); }
41
42 // Runs once the transfer succeeds; the file destination promotes its temp file here.
44 const std::shared_ptr<DownloadTransferState>& state) const = 0;
45
46 // Runs on failure; the file destination removes the temp file the CRT left behind. Empty on
47 // success; otherwise an error the caller can surface alongside the transfer's own failure.
48 virtual OptionalError CleanupOnFailure(const std::shared_ptr<DownloadTransferState>& state) const = 0;
49
50 // Empty unless this request downloads to a file, in which case the CRT writes the file directly.
51 virtual const Aws::String& GetDestinationFilePath() const;
52 virtual const Aws::String& GetTempFilePath() const;
53 // Null unless the customer supplied a receiver, in which case the CRT delivers body chunks to it.
54 virtual const std::shared_ptr<DownloadDataReceiver>& GetDataReceiver() const;
55
57 const Aws::S3::Model::GetObjectRequest& GetS3Request() const { return m_s3Request; }
59
60 protected:
63};
64
65class AWS_CORE_LOCAL FileDownloadImpl final : public DownloadRequestImpl {
66 public:
68 Aws::String key,
69 Aws::String destinationFilePath,
70 Aws::Vector<std::shared_ptr<DownloadProgressListener>> transferListeners);
71
72 OptionalError Validate() const override;
74 const std::shared_ptr<DownloadTransferState>& state) const override;
75 OptionalError CleanupOnFailure(const std::shared_ptr<DownloadTransferState>& state) const override;
76 const Aws::String& GetDestinationFilePath() const override { return m_destinationFilePath; }
77 const Aws::String& GetTempFilePath() const override { return m_tempFilePath; }
78
79 private:
80 Aws::String m_destinationFilePath;
81 Aws::String m_tempFilePath;
82};
83
84class AWS_CORE_LOCAL StreamDownloadImpl final : public DownloadRequestImpl {
85 public:
87 Aws::String key,
88 std::shared_ptr<DownloadDataReceiver> dataReceiver,
89 Aws::Vector<std::shared_ptr<DownloadProgressListener>> transferListeners);
90
92 const std::shared_ptr<DownloadTransferState>& state) const override;
93 OptionalError CleanupOnFailure(const std::shared_ptr<DownloadTransferState>& state) const override;
94 const std::shared_ptr<DownloadDataReceiver>& GetDataReceiver() const override { return m_dataReceiver; }
95
96 private:
97 std::shared_ptr<DownloadDataReceiver> m_dataReceiver;
98};
99
100} // namespace Internal
101} // namespace Transfer
102} // namespace S3
103} // namespace Aws
DownloadRequestImpl & operator=(DownloadRequestImpl &&)=delete
Aws::Vector< std::shared_ptr< DownloadProgressListener > > m_transferListeners
DownloadRequestImpl(const DownloadRequestImpl &)=delete
virtual const Aws::String & GetTempFilePath() const
virtual const Aws::String & GetDestinationFilePath() const
DownloadRequestImpl & operator=(const DownloadRequestImpl &)=delete
DownloadRequestImpl(DownloadRequestImpl &&)=delete
virtual OptionalError FinalizeOnSuccess(const std::shared_ptr< DownloadTransferState > &state) const =0
Aws::S3::Model::GetObjectRequest & MutableS3Request()
const Aws::S3::Model::GetObjectRequest & GetS3Request() const
virtual OptionalError CleanupOnFailure(const std::shared_ptr< DownloadTransferState > &state) const =0
virtual const std::shared_ptr< DownloadDataReceiver > & GetDataReceiver() const
DownloadRequestImpl(Aws::String bucket, Aws::String key, Aws::Vector< std::shared_ptr< DownloadProgressListener > > transferListeners)
const Aws::Vector< std::shared_ptr< DownloadProgressListener > > & GetTransferListeners() const
FileDownloadImpl(Aws::String bucket, Aws::String key, Aws::String destinationFilePath, Aws::Vector< std::shared_ptr< DownloadProgressListener > > transferListeners)
const Aws::String & GetTempFilePath() const override
OptionalError CleanupOnFailure(const std::shared_ptr< DownloadTransferState > &state) const override
const Aws::String & GetDestinationFilePath() const override
OptionalError FinalizeOnSuccess(const std::shared_ptr< DownloadTransferState > &state) const override
OptionalError Validate() const override
StreamDownloadImpl(Aws::String bucket, Aws::String key, std::shared_ptr< DownloadDataReceiver > dataReceiver, Aws::Vector< std::shared_ptr< DownloadProgressListener > > transferListeners)
const std::shared_ptr< DownloadDataReceiver > & GetDataReceiver() const override
OptionalError CleanupOnFailure(const std::shared_ptr< DownloadTransferState > &state) const override
OptionalError FinalizeOnSuccess(const std::shared_ptr< DownloadTransferState > &state) const override
Aws::Crt::Optional< Aws::Client::AWSError< Aws::S3::S3Errors > > OptionalError
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
std::vector< T, Aws::Allocator< T > > Vector