8#include <aws/transfer/TransferHandle.h>
9#include <aws/s3/S3Client.h>
10#include <aws/s3/model/PutObjectRequest.h>
11#include <aws/s3/model/GetObjectRequest.h>
12#include <aws/s3/model/HeadObjectRequest.h>
13#include <aws/s3/model/CreateMultipartUploadRequest.h>
14#include <aws/s3/model/UploadPartRequest.h>
15#include <aws/s3/model/CompletedPart.h>
16#include <aws/core/utils/threading/Executor.h>
17#include <aws/core/utils/memory/stl/AWSStreamFwd.h>
18#include <aws/core/utils/ResourceManager.h>
19#include <aws/core/client/AsyncCallerContext.h>
27 class TransferManager;
35 const uint64_t
MB5 = 5 * 1024 * 1024;
65 std::shared_ptr<Aws::Utils::Threading::Executor>
spExecutor =
nullptr;
157 class AWS_TRANSFER_API
TransferManager :
public std::enable_shared_from_this<TransferManager>
193 const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context =
nullptr);
199 std::shared_ptr<TransferHandle>
UploadFile(
const std::shared_ptr<Aws::IOStream>& stream,
204 const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context =
nullptr);
213 const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context =
nullptr);
222 const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context =
nullptr);
230 uint64_t downloadBytes,
234 const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context =
nullptr);
239 std::shared_ptr<TransferHandle>
RetryDownload(
const std::shared_ptr<TransferHandle>& retryHandle);
244 std::shared_ptr<TransferHandle>
RetryUpload(
const Aws::String& fileName,
const std::shared_ptr<TransferHandle>& retryHandle);
248 std::shared_ptr<TransferHandle>
RetryUpload(
const std::shared_ptr<Aws::IOStream>& stream,
const std::shared_ptr<TransferHandle>& retryHandle);
289 std::shared_ptr<TransferHandle> CreateUploadFileHandle(
Aws::IOStream* fileStream,
295 const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context,
301 std::shared_ptr<TransferHandle> SubmitUpload(
const std::shared_ptr<TransferHandle>& handle,
const std::shared_ptr<Aws::IOStream>& fileStream =
nullptr);
303 bool MultipartUploadSupported(uint64_t length)
const;
304 bool InitializePartsForDownload(
const std::shared_ptr<TransferHandle>& handle);
306 void DoMultiPartUpload(
const std::shared_ptr<Aws::IOStream>& streamToPut,
const std::shared_ptr<TransferHandle>& handle);
307 void DoSinglePartUpload(
const std::shared_ptr<Aws::IOStream>& streamToPut,
const std::shared_ptr<TransferHandle>& handle);
309 void DoMultiPartUpload(
const std::shared_ptr<TransferHandle>& handle);
310 void DoSinglePartUpload(
const std::shared_ptr<TransferHandle>& handle);
312 void DoDownload(
const std::shared_ptr<TransferHandle>& handle);
313 void DoSinglePartDownload(
const std::shared_ptr<TransferHandle>& handle);
318 const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context);
320 void WaitForCancellationAndAbortUpload(
const std::shared_ptr<TransferHandle>& canceledHandle);
327 void TriggerUploadProgressCallback(
const std::shared_ptr<const TransferHandle>&)
const;
328 void TriggerDownloadProgressCallback(
const std::shared_ptr<const TransferHandle>&)
const;
329 void TriggerTransferStatusUpdatedCallback(
const std::shared_ptr<const TransferHandle>&)
const;
336 void AddTask(std::shared_ptr<TransferHandle> handle);
337 void RemoveTask(
const std::shared_ptr<TransferHandle>& handle);
352 mutable std::condition_variable m_tasksSignal;
353 mutable std::mutex m_tasksMutex;
TransferStatus WaitUntilAllFinished(int64_t timeoutMs=std::numeric_limits< int64_t >::max())
std::shared_ptr< TransferHandle > DownloadFile(const Aws::String &bucketName, const Aws::String &keyName, const Aws::String &writeToFile, const DownloadConfiguration &downloadConfig=DownloadConfiguration(), const std::shared_ptr< const Aws::Client::AsyncCallerContext > &context=nullptr)
void UploadDirectory(const Aws::String &directory, const Aws::String &bucketName, const Aws::String &prefix, const Aws::Map< Aws::String, Aws::String > &metadata)
std::shared_ptr< TransferHandle > DownloadFile(const Aws::String &bucketName, const Aws::String &keyName, uint64_t fileOffset, uint64_t downloadBytes, CreateDownloadStreamCallback writeToStreamfn, const DownloadConfiguration &downloadConfig=DownloadConfiguration(), const Aws::String &writeToFile="", const std::shared_ptr< const Aws::Client::AsyncCallerContext > &context=nullptr)
std::shared_ptr< TransferHandle > RetryUpload(const Aws::String &fileName, const std::shared_ptr< TransferHandle > &retryHandle)
std::shared_ptr< TransferHandle > DownloadFile(const Aws::String &bucketName, const Aws::String &keyName, CreateDownloadStreamCallback writeToStreamfn, const DownloadConfiguration &downloadConfig=DownloadConfiguration(), const Aws::String &writeToFile="", const std::shared_ptr< const Aws::Client::AsyncCallerContext > &context=nullptr)
std::shared_ptr< TransferHandle > RetryUpload(const std::shared_ptr< Aws::IOStream > &stream, const std::shared_ptr< TransferHandle > &retryHandle)
std::shared_ptr< TransferHandle > RetryDownload(const std::shared_ptr< TransferHandle > &retryHandle)
std::shared_ptr< TransferHandle > UploadFile(const Aws::String &fileName, const Aws::String &bucketName, const Aws::String &keyName, const Aws::String &contentType, const Aws::Map< Aws::String, Aws::String > &metadata, const std::shared_ptr< const Aws::Client::AsyncCallerContext > &context=nullptr)
void AbortMultipartUpload(const std::shared_ptr< TransferHandle > &inProgressHandle)
static bool IsWithinParentDirectory(Aws::String parentDirectory, Aws::String filePath)
static std::shared_ptr< TransferManager > Create(const TransferManagerConfiguration &config)
void DownloadToDirectory(const Aws::String &directory, const Aws::String &bucketName, const Aws::String &prefix=Aws::String())
std::shared_ptr< TransferHandle > UploadFile(const std::shared_ptr< Aws::IOStream > &stream, const Aws::String &bucketName, const Aws::String &keyName, const Aws::String &contentType, const Aws::Map< Aws::String, Aws::String > &metadata, const std::shared_ptr< const Aws::Client::AsyncCallerContext > &context=nullptr)
std::function< void(const TransferManager *, const std::shared_ptr< const TransferHandle > &, const Aws::Client::AWSError< Aws::S3::S3Errors > &)> ErrorCallback
std::function< void(const TransferManager *, const std::shared_ptr< const TransferHandle > &)> TransferStatusUpdatedCallback
std::function< void(const TransferManager *, const std::shared_ptr< const TransferHandle > &)> DownloadProgressCallback
std::function< void(const TransferManager *, const std::shared_ptr< const TransferHandle > &)> UploadProgressCallback
std::function< void(const TransferManager *, const std::shared_ptr< const TransferHandle > &)> TransferInitiatedCallback
std::function< Aws::IOStream *(void)> CreateDownloadStreamCallback
std::map< K, V, std::less< K >, Aws::Allocator< std::pair< const K, V > > > Map
std::basic_iostream< char, std::char_traits< char > > IOStream
std::unordered_set< T, std::hash< T >, std::equal_to< T >, Aws::Allocator< T > > UnorderedSet
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Aws::S3::Model::CreateMultipartUploadRequest createMultipartUploadTemplate
Aws::Utils::Threading::Executor * transferExecutor
Aws::S3::Model::GetObjectRequest getObjectTemplate
std::shared_ptr< Aws::S3::S3Client > s3Client
UploadProgressCallback uploadProgressCallback
DownloadProgressCallback downloadProgressCallback
uint64_t transferBufferMaxHeapSize
TransferStatusUpdatedCallback transferStatusUpdatedCallback
Aws::S3::Model::ChecksumAlgorithm checksumAlgorithm
Aws::Map< Aws::String, Aws::String > customizedAccessLogTag
Aws::S3::Model::UploadPartRequest uploadPartTemplate
std::function< std::shared_ptr< Utils::Threading::Executor >()> executorCreateFn
std::shared_ptr< Aws::Utils::Threading::Executor > spExecutor
ErrorCallback errorCallback
TransferInitiatedCallback transferInitiatedCallback
Aws::S3::Model::HeadObjectRequest headObjectTemplate
Aws::S3::Model::PutObjectRequest putObjectTemplate
TransferManagerConfiguration(Aws::Utils::Threading::Executor *executor)