diff --git a/cmake/sdks.cmake b/cmake/sdks.cmake index 28c0db501f0..4182fcc0f66 100644 --- a/cmake/sdks.cmake +++ b/cmake/sdks.cmake @@ -2,7 +2,7 @@ include(sdksCommon) set(SDK_DEPENDENCY_BUILD_LIST "") -set(NON_GENERATED_CLIENT_LIST access-management text-to-speech core queues s3-encryption identity-management transfer) ## Manually generated code with a name mimicking client name +set(NON_GENERATED_CLIENT_LIST access-management text-to-speech core queues s3-encryption identity-management transfer s3-transfer) ## Manually generated code with a name mimicking client name if(REGENERATE_CLIENTS OR REGENERATE_DEFAULTS) message(STATUS "Checking for SDK generation requirements") diff --git a/cmake/sdksCommon.cmake b/cmake/sdksCommon.cmake index a0220c83188..fc3bcc18023 100644 --- a/cmake/sdksCommon.cmake +++ b/cmake/sdksCommon.cmake @@ -80,6 +80,7 @@ list(APPEND HIGH_LEVEL_SDK_LIST "access-management") list(APPEND HIGH_LEVEL_SDK_LIST "identity-management") list(APPEND HIGH_LEVEL_SDK_LIST "queues") list(APPEND HIGH_LEVEL_SDK_LIST "transfer") +list(APPEND HIGH_LEVEL_SDK_LIST "s3-transfer") list(APPEND HIGH_LEVEL_SDK_LIST "s3-encryption") list(APPEND HIGH_LEVEL_SDK_LIST "text-to-speech") @@ -141,6 +142,7 @@ list(APPEND SDK_DEPENDENCY_LIST "queues:sqs,core") list(APPEND SDK_DEPENDENCY_LIST "s3-encryption:s3,kms,core") list(APPEND SDK_DEPENDENCY_LIST "text-to-speech:polly,core") list(APPEND SDK_DEPENDENCY_LIST "transfer:s3,core") +list(APPEND SDK_DEPENDENCY_LIST "s3-transfer:s3,core") set(TEST_DEPENDENCY_LIST "") list(APPEND TEST_DEPENDENCY_LIST "cognito-identity:access-management,iam,core") diff --git a/src/aws-cpp-sdk-s3-transfer/CMakeLists.txt b/src/aws-cpp-sdk-s3-transfer/CMakeLists.txt new file mode 100644 index 00000000000..1dc3248f857 --- /dev/null +++ b/src/aws-cpp-sdk-s3-transfer/CMakeLists.txt @@ -0,0 +1,61 @@ +add_project(aws-cpp-sdk-s3-transfer + "High-level CRT-backed C++ SDK for file transfer to/from AWS S3" + aws-cpp-sdk-s3 + aws-cpp-sdk-core) + +file( GLOB S3_TRANSFER_HEADERS "include/aws/s3-transfer/*.h" ) + +file( GLOB S3_TRANSFER_SOURCE "source/s3-transfer/*.cpp" ) + +file( GLOB S3_TRANSFER_INTERNAL_HEADERS "include/aws/s3-transfer/internal/*.h" ) +file( GLOB S3_TRANSFER_INTERNAL_SOURCE "source/s3-transfer/internal/*.cpp" ) + +if(MSVC) + source_group("Header Files\\aws\\s3-transfer" FILES ${S3_TRANSFER_HEADERS}) + source_group("Source Files\\s3-transfer" FILES ${S3_TRANSFER_SOURCE}) + source_group("Header Files\\aws\\s3-transfer\\internal" FILES ${S3_TRANSFER_INTERNAL_HEADERS}) + source_group("Source Files\\s3-transfer\\internal" FILES ${S3_TRANSFER_INTERNAL_SOURCE}) +endif() + +file(GLOB ALL_S3_TRANSFER_HEADERS + ${S3_TRANSFER_HEADERS} + ${S3_TRANSFER_INTERNAL_HEADERS} +) + +file(GLOB ALL_S3_TRANSFER_SOURCE + ${S3_TRANSFER_SOURCE} + ${S3_TRANSFER_INTERNAL_SOURCE} +) + +file(GLOB ALL_S3_TRANSFER + ${ALL_S3_TRANSFER_HEADERS} + ${ALL_S3_TRANSFER_SOURCE} +) + +set(S3_TRANSFER_INCLUDES + "${CMAKE_CURRENT_SOURCE_DIR}/include/" +) + +include_directories(${S3_TRANSFER_INCLUDES}) + +if(USE_WINDOWS_DLL_SEMANTICS AND BUILD_SHARED_LIBS) + add_definitions("-DAWS_S3_TRANSFER_EXPORTS") +endif() + +add_library(${PROJECT_NAME} ${ALL_S3_TRANSFER}) +add_library(AWS::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) + +target_include_directories(${PROJECT_NAME} PUBLIC + $ + $) +target_link_libraries(${PROJECT_NAME} PRIVATE ${PLATFORM_DEP_LIBS} ${PROJECT_LIBS}) + +set_compiler_flags(${PROJECT_NAME}) +set_compiler_warnings(${PROJECT_NAME}) + +setup_install() + +install (FILES ${S3_TRANSFER_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/s3-transfer) +install (FILES ${S3_TRANSFER_INTERNAL_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/s3-transfer/internal) + +do_packaging() diff --git a/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/DownloadHandle.h b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/DownloadHandle.h new file mode 100644 index 00000000000..895f813cb0e --- /dev/null +++ b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/DownloadHandle.h @@ -0,0 +1,47 @@ +/** +* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#pragma once +#include +#include +#include +#include + + +namespace Aws { +namespace S3 { +namespace Transfer { + +class DownloadHandleImpl; + +/** + * Returned from S3TransferManager::Download to represent a single in-flight download. The + * handle is freely copyable; all copies share the same underlying transfer state. + */ +class AWS_S3_TRANSFER_API DownloadHandle final { +public: + DownloadHandle(); + ~DownloadHandle(); + DownloadHandle(DownloadHandle&&) noexcept; + DownloadHandle& operator=(DownloadHandle&&) noexcept; + + /** + * Returns a future that resolves once the transfer finishes, succeeds, or fails. + */ + std::future CompletionFuture(); + + /** + * Requests cancellation of the in-flight download. Returns immediately; the future + * returned by CompletionFuture will resolve with a failure once the cancel takes effect. + */ + void Cancel(); + +private: + Aws::UniquePtr m_impl; +}; + + +} +} +} diff --git a/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/DownloadProgressListener.h b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/DownloadProgressListener.h new file mode 100644 index 00000000000..6e5f2a9a378 --- /dev/null +++ b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/DownloadProgressListener.h @@ -0,0 +1,26 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#pragma once +#include +#include +#include + +namespace Aws { +namespace S3 { +namespace Transfer { + +class DownloadRequest; + +/** + * Callback interface for receiving event-driven updates throughout the lifecycle of a download. + * Subclass and override the events of interest; default implementations are empty so unused + * callbacks can be ignored. Listeners may be registered on the request or on the manager. + */ +class AWS_S3_TRANSFER_API DownloadProgressListener + : public ProgressListener {}; + +} +} +} diff --git a/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/DownloadProgressSnapshot.h b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/DownloadProgressSnapshot.h new file mode 100644 index 00000000000..2e0791a9e0a --- /dev/null +++ b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/DownloadProgressSnapshot.h @@ -0,0 +1,26 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#pragma once +#include +#include +#include + +namespace Aws { +namespace S3 { +namespace Transfer { + +/** + * Immutable snapshot of download progress passed to DownloadProgressListener callbacks. + * Captures bytes transferred, total bytes (known after the GetObject response is received), + * and the response once available. + */ +class AWS_S3_TRANSFER_API DownloadProgressSnapshot final : public ProgressSnapshot { + public: + using ProgressSnapshot::ProgressSnapshot; +}; + +} +} +} diff --git a/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/DownloadRequest.h b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/DownloadRequest.h new file mode 100644 index 00000000000..69eb938e2d5 --- /dev/null +++ b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/DownloadRequest.h @@ -0,0 +1,53 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#pragma once +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Aws { +namespace S3 { +namespace Transfer { + +/** + * Request type for S3TransferManager::Download. Carries the inner S3 GetObjectRequest along + * with the local destination (file path or stream factory) and any request-level progress + * listeners. The transfer manager parallelizes large objects via ranged GETs internally. + */ +class AWS_S3_TRANSFER_API DownloadRequest final { + public: + explicit DownloadRequest( + Aws::S3::Model::GetObjectRequest s3Request, + Aws::String destinationFilePath, + Aws::IOStreamFactory responseStreamFactory, + Aws::Vector> transferListeners = {}) + : m_s3Request(std::move(s3Request)), + m_destinationFilePath(std::move(destinationFilePath)), + m_responseStreamFactory(std::move(responseStreamFactory)), + m_transferListeners(std::move(transferListeners)) {} + + inline const Aws::S3::Model::GetObjectRequest& GetS3Request() const { return m_s3Request; } + inline const Aws::String& GetDestinationFilePath() const { return m_destinationFilePath; } + inline const Aws::IOStreamFactory& GetResponseStreamFactory() const { return m_responseStreamFactory; } + inline const Aws::Vector>& GetTransferListeners() const { + return m_transferListeners; + } + + + private: + Aws::S3::Model::GetObjectRequest m_s3Request; + Aws::String m_destinationFilePath; + Aws::IOStreamFactory m_responseStreamFactory; + Aws::Vector> m_transferListeners; +}; + +} +} +} diff --git a/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/DownloadResponse.h b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/DownloadResponse.h new file mode 100644 index 00000000000..8aa84699b28 --- /dev/null +++ b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/DownloadResponse.h @@ -0,0 +1,46 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#pragma once +#include +#include +#include +#include +#include +#include + +namespace Aws { +namespace S3 { +namespace Transfer { + +/** + * Response type returned via the DownloadHandle's future once the transfer completes. Wraps + * the underlying S3 GetObjectResult with whole-object content length and range, regardless + * of how many ranged GETs were issued internally. + */ +class AWS_S3_TRANSFER_API DownloadResponse final { + public: + inline const Aws::S3::Model::GetObjectResult& GetS3Result() const { return m_s3Result; } + inline bool S3ResultHasBeenSet() const { return m_s3ResultHasBeenSet; } + template + void SetS3Result(GetObjectResultT&& getS3Result) { + m_s3ResultHasBeenSet = true; + m_s3Result = std::forward(getS3Result); + } + template + DownloadResponse& WithS3Result(GetObjectResultT&& getS3Result) { + SetS3Result(std::forward(getS3Result)); + return *this; + } + + private: + Aws::S3::Model::GetObjectResult m_s3Result; + bool m_s3ResultHasBeenSet = false; +}; + +using DownloadOutcome = Aws::Utils::Outcome>; + +} +} +} diff --git a/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/ProgressListener.h b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/ProgressListener.h new file mode 100644 index 00000000000..d345f10242b --- /dev/null +++ b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/ProgressListener.h @@ -0,0 +1,47 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#pragma once +#include + +namespace Aws { +namespace S3 { +namespace Transfer { + +/** + * Callback interface for receiving event-driven updates throughout the lifecycle of a transfer. + * Subclass and override the events of interest; default implementations are empty so unused + * callbacks can be ignored. Listeners may be registered on the request or on the manager. + * Specialized via the UploadProgressListener and DownloadProgressListener type aliases. + */ +template +class ProgressListener { + public: + virtual ~ProgressListener() = default; + + /** + * Invoked exactly once when the transfer begins, before any bytes have been transferred. + */ + virtual void OnTransferInitiated(const RequestT& /*request*/, const SnapshotT& /*snapshot*/) {} + + /** + * Invoked as bytes are transferred. Called at least once for a successful transfer + * and may be called many times depending on object size and I/O buffer sizes. + */ + virtual void OnBytesTransferred(const RequestT& /*request*/, const SnapshotT& /*snapshot*/) {} + + /** + * Invoked exactly once when the transfer completes successfully. + */ + virtual void OnTransferComplete(const RequestT& /*request*/, const SnapshotT& /*snapshot*/) {} + + /** + * Invoked exactly once when the transfer fails or is cancelled. + */ + virtual void OnTransferFailed(const RequestT& /*request*/, const SnapshotT& /*snapshot*/) {} +}; + +} +} +} diff --git a/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/ProgressSnapshot.h b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/ProgressSnapshot.h new file mode 100644 index 00000000000..18ef7898d85 --- /dev/null +++ b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/ProgressSnapshot.h @@ -0,0 +1,49 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#pragma once +#include +#include +#include +#include + +namespace Aws { +namespace S3 { +namespace Transfer { + +/** + * Immutable snapshot of transfer progress passed to ProgressListener callbacks. Captures + * bytes transferred, total bytes, and the response once available. Specialized via the + * UploadProgressSnapshot and DownloadProgressSnapshot type aliases. + */ +template +class ProgressSnapshot { + public: + virtual ~ProgressSnapshot() = default; + + ProgressSnapshot(uint64_t transferredBytes, + uint64_t totalBytes, + std::shared_ptr response, + bool totalBytesHasBeenSet) + : m_transferredBytes(transferredBytes), + m_totalBytes(totalBytes), + m_response(std::move(response)), + m_totalBytesHasBeenSet(totalBytesHasBeenSet) {} + + inline uint64_t GetTransferredBytes() const { return m_transferredBytes; } + inline uint64_t GetTotalBytes() const { return m_totalBytes; } + inline bool TotalBytesHasBeenSet() const { return m_totalBytesHasBeenSet; } + inline const std::shared_ptr& GetResponse() const { return m_response; } + inline bool ResponseHasBeenSet() const { return m_response != nullptr; } + + private: + uint64_t m_transferredBytes = 0; + uint64_t m_totalBytes = 0; + std::shared_ptr m_response; + bool m_totalBytesHasBeenSet = false; +}; + +} +} +} diff --git a/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/S3TransferManager.h b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/S3TransferManager.h new file mode 100644 index 00000000000..52c5b03ae46 --- /dev/null +++ b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/S3TransferManager.h @@ -0,0 +1,51 @@ +/** +* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#pragma once +#include +#include +#include +#include +#include +#include +#include +namespace Aws { + namespace S3 { + namespace Transfer { + class S3TransferManagerImpl; + + /** + * Customers construct an instance directly. The manager owns the underlying CRT + * client; it is movable but not copyable. + */ + class AWS_S3_TRANSFER_API S3TransferManager final { + public: + explicit S3TransferManager(const S3TransferManagerConfiguration& config); + ~S3TransferManager(); + + S3TransferManager(const S3TransferManager&) = delete; + S3TransferManager& operator=(const S3TransferManager&) = delete; + + + /** + * Begin uploading the object described by request. Returns immediately with a handle + * that can be used to wait for completion or to cancel the in-flight transfer. + */ + UploadHandle Upload(const UploadRequest& request); + + /** + * Begin downloading the object described by request. Returns immediately with a handle + * that can be used to wait for completion or to cancel the in-flight transfer. + */ + DownloadHandle Download(const DownloadRequest& request); + + private: + Aws::UniquePtr m_impl; + }; + } + } + } + + + diff --git a/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/S3TransferManagerConfiguration.h b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/S3TransferManagerConfiguration.h new file mode 100644 index 00000000000..f8cd24fa03f --- /dev/null +++ b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/S3TransferManagerConfiguration.h @@ -0,0 +1,18 @@ +/** +* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#pragma once +#include + + +namespace Aws { + namespace S3 { + namespace Transfer { + class AWS_S3_TRANSFER_API S3TransferManagerConfiguration { + //need to fill in class definition later + }; + } + } +} + diff --git a/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/S3Transfer_EXPORTS.h b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/S3Transfer_EXPORTS.h new file mode 100644 index 00000000000..fe7636bb906 --- /dev/null +++ b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/S3Transfer_EXPORTS.h @@ -0,0 +1,28 @@ +/** +* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#pragma once + +#ifdef _MSC_VER + //disable windows complaining about max template size. + #pragma warning (disable : 4503) +#endif + +#if defined (USE_WINDOWS_DLL_SEMANTICS) || defined (_WIN32) + #ifdef _MSC_VER + #pragma warning(disable : 4251) + #endif // _MSC_VER + + #ifdef USE_IMPORT_EXPORT + #ifdef AWS_S3_TRANSFER_EXPORTS + #define AWS_S3_TRANSFER_API __declspec(dllexport) + #else + #define AWS_S3_TRANSFER_API __declspec(dllimport) + #endif // AWS_S3_TRANSFER_EXPORTS + #else // USE_IMPORT_EXPORT + #define AWS_S3_TRANSFER_API + #endif // USE_IMPORT_EXPORT +#else // defined (USE_WINDOWS_DLL_SEMANTICS) || defined (_WIN32) + #define AWS_S3_TRANSFER_API +#endif // defined (USE_WINDOWS_DLL_SEMANTICS) || defined (_WIN32) diff --git a/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/UploadHandle.h b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/UploadHandle.h new file mode 100644 index 00000000000..5e6b893a96d --- /dev/null +++ b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/UploadHandle.h @@ -0,0 +1,48 @@ +/** +* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#pragma once +#include +#include +#include +#include + + +namespace Aws { +namespace S3 { +namespace Transfer { + +class UploadHandleImpl; + +/** + * Returned from S3TransferManager::Upload to represent a single in-flight upload. The + * handle is freely copyable; all copies share the same underlying transfer state. + */ +class AWS_S3_TRANSFER_API UploadHandle final { +public: + UploadHandle(); + ~UploadHandle(); + UploadHandle(UploadHandle&&) noexcept; + UploadHandle& operator=(UploadHandle&&) noexcept; + + + /** + * Returns a future that resolves once the transfer finishes, succeeds, or fails. + */ + std::future CompletionFuture(); + + /** + * Requests cancellation of the in-flight upload. Returns immediately; the future + * returned by CompletionFuture will resolve with a failure once the cancel takes effect. + */ + void Cancel(); + +private: + Aws::UniquePtr m_impl; +}; + + +} +} +} diff --git a/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/UploadProgressListener.h b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/UploadProgressListener.h new file mode 100644 index 00000000000..dc018930441 --- /dev/null +++ b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/UploadProgressListener.h @@ -0,0 +1,26 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#pragma once +#include +#include +#include + +namespace Aws { +namespace S3 { +namespace Transfer { + +class UploadRequest; + +/** + * Callback interface for receiving event-driven updates throughout the lifecycle of an upload. + * Subclass and override the events of interest; default implementations are empty so unused + * callbacks can be ignored. Listeners may be registered on the request or on the manager. + */ +class AWS_S3_TRANSFER_API UploadProgressListener + : public ProgressListener {}; + +} +} +} diff --git a/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/UploadProgressSnapshot.h b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/UploadProgressSnapshot.h new file mode 100644 index 00000000000..430b40dca97 --- /dev/null +++ b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/UploadProgressSnapshot.h @@ -0,0 +1,25 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#pragma once +#include +#include +#include + +namespace Aws { +namespace S3 { +namespace Transfer { + +/** + * Immutable snapshot of upload progress passed to UploadProgressListener callbacks. Captures + * bytes transferred, total bytes (known up-front for uploads), and the response once available. + */ +class AWS_S3_TRANSFER_API UploadProgressSnapshot final : public ProgressSnapshot { + public: + using ProgressSnapshot::ProgressSnapshot; +}; + +} +} +} diff --git a/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/UploadRequest.h b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/UploadRequest.h new file mode 100644 index 00000000000..b284a7bead1 --- /dev/null +++ b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/UploadRequest.h @@ -0,0 +1,53 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#pragma once +#include +#include +#include +#include +#include +#include +#include + +namespace Aws { +namespace S3 { +namespace Transfer { + +/** + * Request type for S3TransferManager::Upload. Carries the inner S3 PutObjectRequest along + * with the local source (file path or stream) and any request-level progress listeners. + * The transfer manager chooses between a single PutObject and a multipart upload based on + * the configured threshold. + */ +class AWS_S3_TRANSFER_API UploadRequest final { + public: + explicit UploadRequest( + Aws::S3::Model::PutObjectRequest s3Request, + Aws::String sourceFilePath, + std::shared_ptr body, + Aws::Vector> transferListeners = {}) + : m_s3Request(std::move(s3Request)), + m_sourceFilePath(std::move(sourceFilePath)), + m_body(std::move(body)), + m_transferListeners(std::move(transferListeners)) {} + + inline const Aws::S3::Model::PutObjectRequest& GetS3Request() const {return m_s3Request; } + inline const Aws::String& GetSourceFilePath() const {return m_sourceFilePath;} + inline const std::shared_ptr& GetBody() const {return m_body;} + inline const Aws::Vector>& GetTransferListeners() const { + return m_transferListeners; + } + + + private: + Aws::S3::Model::PutObjectRequest m_s3Request; + Aws::String m_sourceFilePath; + std::shared_ptr m_body; + Aws::Vector> m_transferListeners; +}; + +} +} +} diff --git a/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/UploadResponse.h b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/UploadResponse.h new file mode 100644 index 00000000000..e5618229def --- /dev/null +++ b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/UploadResponse.h @@ -0,0 +1,46 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#pragma once +#include +#include +#include +#include +#include +#include + +namespace Aws { +namespace S3 { +namespace Transfer { + +/** + * Response type returned via the UploadHandle's future once the transfer completes. Wraps + * the underlying S3 PutObjectResult, populated from either the single PutObject response + * or the CompleteMultipartUpload response depending on the path taken. + */ +class AWS_S3_TRANSFER_API UploadResponse final { + public: + inline const Aws::S3::Model::PutObjectResult& GetS3Result() const { return m_s3Result; } + inline bool S3ResultHasBeenSet() const { return m_s3ResultHasBeenSet; } + template + void SetS3Result(S3ResultT&& s3Result) { + m_s3ResultHasBeenSet = true; + m_s3Result = std::forward(s3Result); + } + template + UploadResponse& WithS3Result(S3ResultT&& s3Result) { + SetS3Result(std::forward(s3Result)); + return *this; + } + + private: + Aws::S3::Model::PutObjectResult m_s3Result; + bool m_s3ResultHasBeenSet = false; +}; + +using UploadOutcome = Aws::Utils::Outcome>; + +} +} +} diff --git a/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/internal/CrtOperations.h b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/internal/CrtOperations.h new file mode 100644 index 00000000000..b45a188732f --- /dev/null +++ b/src/aws-cpp-sdk-s3-transfer/include/aws/s3-transfer/internal/CrtOperations.h @@ -0,0 +1,43 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#pragma once + +#include +#include +#include +#include + +namespace Aws { +namespace S3 { +namespace Transfer { + +class S3TransferManagerImpl; + +namespace Internal { + +/** + * Bridges TM 2.0 to the aws-crt-cpp S3 wrapper. Stays in C++; does not call + * aws-c-s3 directly. Internal; not part of the public API. + */ +class CrtOperations final { + + public: + /** + * Dispatch an upload as a CRT meta request. Returns a handle bound to the + * in-flight request. + */ + static UploadHandle DispatchUpload(S3TransferManagerImpl& impl, const UploadRequest& request); + + /** + * Dispatch a download as a CRT meta request. Returns a handle bound to the + * in-flight request. + */ + static DownloadHandle DispatchDownload(S3TransferManagerImpl& impl, const DownloadRequest& request); +}; + +} +} +} +} diff --git a/src/aws-cpp-sdk-s3-transfer/source/s3-transfer/DownloadHandle.cpp b/src/aws-cpp-sdk-s3-transfer/source/s3-transfer/DownloadHandle.cpp new file mode 100644 index 00000000000..e8189b20e69 --- /dev/null +++ b/src/aws-cpp-sdk-s3-transfer/source/s3-transfer/DownloadHandle.cpp @@ -0,0 +1,26 @@ +/** +* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + #include + + namespace Aws { + namespace S3 { + namespace Transfer { + class DownloadHandleImpl { + + }; + DownloadHandle::~DownloadHandle() = default; + DownloadHandle::DownloadHandle() = default; + DownloadHandle::DownloadHandle(DownloadHandle&&) noexcept = default; + DownloadHandle& DownloadHandle::operator=(DownloadHandle&&) noexcept = default; + + std::future DownloadHandle::CompletionFuture() { + return {}; + } + void DownloadHandle::Cancel() { + + } + } + } + } diff --git a/src/aws-cpp-sdk-s3-transfer/source/s3-transfer/S3TransferManager.cpp b/src/aws-cpp-sdk-s3-transfer/source/s3-transfer/S3TransferManager.cpp new file mode 100644 index 00000000000..baf1d513aa5 --- /dev/null +++ b/src/aws-cpp-sdk-s3-transfer/source/s3-transfer/S3TransferManager.cpp @@ -0,0 +1,31 @@ +/** +* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#include +#include + +namespace Aws { +namespace S3 { +namespace Transfer { +class S3TransferManagerImpl { + +}; +S3TransferManager::~S3TransferManager() = default; + +S3TransferManager::S3TransferManager(const S3TransferManagerConfiguration& ) : +m_impl(Aws::MakeUnique("S3TransferManager")) { + +} + +UploadHandle S3TransferManager::Upload(const UploadRequest&) { + return UploadHandle(); +} + +DownloadHandle S3TransferManager::Download(const DownloadRequest&) { + return DownloadHandle(); +} + +} +} +} diff --git a/src/aws-cpp-sdk-s3-transfer/source/s3-transfer/UploadHandle.cpp b/src/aws-cpp-sdk-s3-transfer/source/s3-transfer/UploadHandle.cpp new file mode 100644 index 00000000000..2d46c4d976a --- /dev/null +++ b/src/aws-cpp-sdk-s3-transfer/source/s3-transfer/UploadHandle.cpp @@ -0,0 +1,27 @@ +/** +* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + #include + + namespace Aws { + namespace S3 { + namespace Transfer { + class UploadHandleImpl { + + }; + UploadHandle::~UploadHandle() = default; + UploadHandle::UploadHandle() = default; + + UploadHandle::UploadHandle(UploadHandle&&) noexcept = default; + UploadHandle& UploadHandle::operator=(UploadHandle&&) noexcept = default; + + std::future UploadHandle::CompletionFuture() { + return {}; + } + void UploadHandle::Cancel() { + + } + } + } + } diff --git a/src/aws-cpp-sdk-s3-transfer/source/s3-transfer/internal/CrtOperations.cpp b/src/aws-cpp-sdk-s3-transfer/source/s3-transfer/internal/CrtOperations.cpp new file mode 100644 index 00000000000..6474dfc6802 --- /dev/null +++ b/src/aws-cpp-sdk-s3-transfer/source/s3-transfer/internal/CrtOperations.cpp @@ -0,0 +1,24 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#include + +namespace Aws { +namespace S3 { +namespace Transfer { +namespace Internal { + +UploadHandle CrtOperations::DispatchUpload(S3TransferManagerImpl&, const UploadRequest&) { + return UploadHandle(); +} + +DownloadHandle CrtOperations::DispatchDownload(S3TransferManagerImpl&, const DownloadRequest&) { + return DownloadHandle(); +} + +} +} +} +}