Skip to content

Commit d257040

Browse files
authored
Adding TM Headers (#3844)
1 parent ee4d04d commit d257040

24 files changed

Lines changed: 844 additions & 1 deletion

cmake/sdks.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ include(sdksCommon)
22

33
set(SDK_DEPENDENCY_BUILD_LIST "")
44

5-
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
5+
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
66

77
if(REGENERATE_CLIENTS OR REGENERATE_DEFAULTS)
88
message(STATUS "Checking for SDK generation requirements")

cmake/sdksCommon.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ list(APPEND HIGH_LEVEL_SDK_LIST "access-management")
8080
list(APPEND HIGH_LEVEL_SDK_LIST "identity-management")
8181
list(APPEND HIGH_LEVEL_SDK_LIST "queues")
8282
list(APPEND HIGH_LEVEL_SDK_LIST "transfer")
83+
list(APPEND HIGH_LEVEL_SDK_LIST "s3-transfer")
8384
list(APPEND HIGH_LEVEL_SDK_LIST "s3-encryption")
8485
list(APPEND HIGH_LEVEL_SDK_LIST "text-to-speech")
8586

@@ -141,6 +142,7 @@ list(APPEND SDK_DEPENDENCY_LIST "queues:sqs,core")
141142
list(APPEND SDK_DEPENDENCY_LIST "s3-encryption:s3,kms,core")
142143
list(APPEND SDK_DEPENDENCY_LIST "text-to-speech:polly,core")
143144
list(APPEND SDK_DEPENDENCY_LIST "transfer:s3,core")
145+
list(APPEND SDK_DEPENDENCY_LIST "s3-transfer:s3,core")
144146

145147
set(TEST_DEPENDENCY_LIST "")
146148
list(APPEND TEST_DEPENDENCY_LIST "cognito-identity:access-management,iam,core")
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
add_project(aws-cpp-sdk-s3-transfer
2+
"High-level CRT-backed C++ SDK for file transfer to/from AWS S3"
3+
aws-cpp-sdk-s3
4+
aws-cpp-sdk-core)
5+
6+
file( GLOB S3_TRANSFER_HEADERS "include/aws/s3-transfer/*.h" )
7+
8+
file( GLOB S3_TRANSFER_SOURCE "source/s3-transfer/*.cpp" )
9+
10+
file( GLOB S3_TRANSFER_INTERNAL_HEADERS "include/aws/s3-transfer/internal/*.h" )
11+
file( GLOB S3_TRANSFER_INTERNAL_SOURCE "source/s3-transfer/internal/*.cpp" )
12+
13+
if(MSVC)
14+
source_group("Header Files\\aws\\s3-transfer" FILES ${S3_TRANSFER_HEADERS})
15+
source_group("Source Files\\s3-transfer" FILES ${S3_TRANSFER_SOURCE})
16+
source_group("Header Files\\aws\\s3-transfer\\internal" FILES ${S3_TRANSFER_INTERNAL_HEADERS})
17+
source_group("Source Files\\s3-transfer\\internal" FILES ${S3_TRANSFER_INTERNAL_SOURCE})
18+
endif()
19+
20+
file(GLOB ALL_S3_TRANSFER_HEADERS
21+
${S3_TRANSFER_HEADERS}
22+
${S3_TRANSFER_INTERNAL_HEADERS}
23+
)
24+
25+
file(GLOB ALL_S3_TRANSFER_SOURCE
26+
${S3_TRANSFER_SOURCE}
27+
${S3_TRANSFER_INTERNAL_SOURCE}
28+
)
29+
30+
file(GLOB ALL_S3_TRANSFER
31+
${ALL_S3_TRANSFER_HEADERS}
32+
${ALL_S3_TRANSFER_SOURCE}
33+
)
34+
35+
set(S3_TRANSFER_INCLUDES
36+
"${CMAKE_CURRENT_SOURCE_DIR}/include/"
37+
)
38+
39+
include_directories(${S3_TRANSFER_INCLUDES})
40+
41+
if(USE_WINDOWS_DLL_SEMANTICS AND BUILD_SHARED_LIBS)
42+
add_definitions("-DAWS_S3_TRANSFER_EXPORTS")
43+
endif()
44+
45+
add_library(${PROJECT_NAME} ${ALL_S3_TRANSFER})
46+
add_library(AWS::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
47+
48+
target_include_directories(${PROJECT_NAME} PUBLIC
49+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
50+
$<INSTALL_INTERFACE:include>)
51+
target_link_libraries(${PROJECT_NAME} PRIVATE ${PLATFORM_DEP_LIBS} ${PROJECT_LIBS})
52+
53+
set_compiler_flags(${PROJECT_NAME})
54+
set_compiler_warnings(${PROJECT_NAME})
55+
56+
setup_install()
57+
58+
install (FILES ${S3_TRANSFER_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/s3-transfer)
59+
install (FILES ${S3_TRANSFER_INTERNAL_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/s3-transfer/internal)
60+
61+
do_packaging()
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0.
4+
*/
5+
#pragma once
6+
#include <aws/s3-transfer/S3Transfer_EXPORTS.h>
7+
#include <future>
8+
#include <memory>
9+
#include <aws/s3-transfer/DownloadResponse.h>
10+
11+
12+
namespace Aws {
13+
namespace S3 {
14+
namespace Transfer {
15+
16+
/**
17+
* Returned from S3TransferManager::Download to represent a single in-flight download. The
18+
* handle is move-only and owns the underlying transfer state.
19+
*/
20+
class AWS_S3_TRANSFER_API DownloadHandle final {
21+
public:
22+
DownloadHandle();
23+
~DownloadHandle();
24+
DownloadHandle(DownloadHandle&&) noexcept;
25+
DownloadHandle& operator=(DownloadHandle&&) noexcept;
26+
27+
/**
28+
* Returns a future that resolves once the transfer finishes, succeeds, or fails.
29+
*/
30+
std::future<DownloadOutcome> CompletionFuture();
31+
32+
/**
33+
* Requests cancellation of the in-flight download. Returns immediately; the future
34+
* returned by CompletionFuture will resolve with a failure once the cancel takes effect.
35+
*/
36+
void Cancel();
37+
};
38+
39+
40+
}
41+
}
42+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0.
4+
*/
5+
#pragma once
6+
#include <aws/s3-transfer/S3Transfer_EXPORTS.h>
7+
#include <aws/s3-transfer/ProgressListener.h>
8+
#include <aws/s3-transfer/DownloadProgressSnapshot.h>
9+
10+
namespace Aws {
11+
namespace S3 {
12+
namespace Transfer {
13+
14+
class DownloadRequest;
15+
16+
/**
17+
* Callback interface for receiving event-driven updates throughout the lifecycle of a download.
18+
* Subclass and override the events of interest; default implementations are empty so unused
19+
* callbacks can be ignored. Listeners may be registered on the request or on the manager.
20+
*/
21+
class AWS_S3_TRANSFER_API DownloadProgressListener
22+
: public ProgressListener<DownloadRequest, DownloadProgressSnapshot> {};
23+
24+
}
25+
}
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0.
4+
*/
5+
#pragma once
6+
#include <aws/s3-transfer/S3Transfer_EXPORTS.h>
7+
#include <aws/s3-transfer/ProgressSnapshot.h>
8+
#include <aws/s3-transfer/DownloadResponse.h>
9+
10+
namespace Aws {
11+
namespace S3 {
12+
namespace Transfer {
13+
14+
/**
15+
* Immutable snapshot of download progress passed to DownloadProgressListener callbacks.
16+
* Captures bytes transferred, total bytes (known after the GetObject response is received),
17+
* and the response once available.
18+
*/
19+
class AWS_S3_TRANSFER_API DownloadProgressSnapshot final : public ProgressSnapshot<DownloadResponse> {
20+
public:
21+
using ProgressSnapshot<DownloadResponse>::ProgressSnapshot;
22+
};
23+
24+
}
25+
}
26+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0.
4+
*/
5+
#pragma once
6+
#include <aws/s3-transfer/S3Transfer_EXPORTS.h>
7+
#include <aws/s3-transfer/DownloadProgressListener.h>
8+
#include <aws/core/utils/memory/stl/AWSString.h>
9+
#include <aws/core/utils/memory/stl/AWSVector.h>
10+
#include <aws/core/utils/stream/ResponseStream.h>
11+
#include <aws/s3/model/GetObjectRequest.h>
12+
#include <memory>
13+
#include <utility>
14+
15+
namespace Aws {
16+
namespace S3 {
17+
namespace Transfer {
18+
19+
/**
20+
* Request type for S3TransferManager::Download. Carries the inner S3 GetObjectRequest along
21+
* with the local destination (file path or stream factory) and any request-level progress
22+
* listeners. The transfer manager parallelizes large objects via ranged GETs internally.
23+
*/
24+
class AWS_S3_TRANSFER_API DownloadRequest final {
25+
public:
26+
explicit DownloadRequest(
27+
Aws::S3::Model::GetObjectRequest s3Request,
28+
Aws::String destinationFilePath,
29+
Aws::IOStreamFactory responseStreamFactory,
30+
Aws::Vector<std::shared_ptr<DownloadProgressListener>> transferListeners = {})
31+
: m_s3Request(std::move(s3Request)),
32+
m_destinationFilePath(std::move(destinationFilePath)),
33+
m_responseStreamFactory(std::move(responseStreamFactory)),
34+
m_transferListeners(std::move(transferListeners)) {}
35+
36+
inline const Aws::S3::Model::GetObjectRequest& GetS3Request() const { return m_s3Request; }
37+
inline const Aws::String& GetDestinationFilePath() const { return m_destinationFilePath; }
38+
inline const Aws::IOStreamFactory& GetResponseStreamFactory() const { return m_responseStreamFactory; }
39+
inline const Aws::Vector<std::shared_ptr<DownloadProgressListener>>& GetTransferListeners() const {
40+
return m_transferListeners;
41+
}
42+
43+
44+
private:
45+
Aws::S3::Model::GetObjectRequest m_s3Request;
46+
Aws::String m_destinationFilePath;
47+
Aws::IOStreamFactory m_responseStreamFactory;
48+
Aws::Vector<std::shared_ptr<DownloadProgressListener>> m_transferListeners;
49+
};
50+
51+
}
52+
}
53+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0.
4+
*/
5+
#pragma once
6+
#include <aws/s3-transfer/S3Transfer_EXPORTS.h>
7+
#include <aws/core/client/AWSError.h>
8+
#include <aws/core/utils/Outcome.h>
9+
#include <aws/s3/S3Errors.h>
10+
#include <aws/s3/model/GetObjectResult.h>
11+
#include <utility>
12+
13+
namespace Aws {
14+
namespace S3 {
15+
namespace Transfer {
16+
17+
/**
18+
* Response type returned via the DownloadHandle's future once the transfer completes. Wraps
19+
* the underlying S3 GetObjectResult with whole-object content length and range, regardless
20+
* of how many ranged GETs were issued internally.
21+
*/
22+
class AWS_S3_TRANSFER_API DownloadResponse final {
23+
public:
24+
inline const Aws::S3::Model::GetObjectResult& GetS3Result() const { return m_s3Result; }
25+
inline bool S3ResultHasBeenSet() const { return m_s3ResultHasBeenSet; }
26+
template <typename GetObjectResultT = Aws::S3::Model::GetObjectResult>
27+
void SetS3Result(GetObjectResultT&& getS3Result) {
28+
m_s3ResultHasBeenSet = true;
29+
m_s3Result = std::forward<GetObjectResultT>(getS3Result);
30+
}
31+
template <typename GetObjectResultT = Aws::S3::Model::GetObjectResult>
32+
DownloadResponse& WithS3Result(GetObjectResultT&& getS3Result) {
33+
SetS3Result(std::forward<GetObjectResultT>(getS3Result));
34+
return *this;
35+
}
36+
37+
private:
38+
Aws::S3::Model::GetObjectResult m_s3Result;
39+
bool m_s3ResultHasBeenSet = false;
40+
};
41+
42+
using DownloadOutcome = Aws::Utils::Outcome<DownloadResponse, Aws::Client::AWSError<Aws::S3::S3Errors>>;
43+
44+
}
45+
}
46+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0.
4+
*/
5+
#pragma once
6+
#include <aws/s3-transfer/S3Transfer_EXPORTS.h>
7+
8+
namespace Aws {
9+
namespace S3 {
10+
namespace Transfer {
11+
12+
/**
13+
* Callback interface for receiving event-driven updates throughout the lifecycle of a transfer.
14+
* Subclass and override the events of interest; default implementations are empty so unused
15+
* callbacks can be ignored. Listeners may be registered on the request or on the manager.
16+
* Specialized via the UploadProgressListener and DownloadProgressListener type aliases.
17+
*/
18+
template <typename RequestT, typename SnapshotT>
19+
class ProgressListener {
20+
public:
21+
virtual ~ProgressListener() = default;
22+
23+
/**
24+
* Invoked exactly once when the transfer begins, before any bytes have been transferred.
25+
*/
26+
virtual void OnTransferInitiated(const RequestT& /*request*/, const SnapshotT& /*snapshot*/) {}
27+
28+
/**
29+
* Invoked as bytes are transferred. Called at least once for a successful transfer
30+
* and may be called many times depending on object size and I/O buffer sizes.
31+
*/
32+
virtual void OnBytesTransferred(const RequestT& /*request*/, const SnapshotT& /*snapshot*/) {}
33+
34+
/**
35+
* Invoked exactly once when the transfer completes successfully.
36+
*/
37+
virtual void OnTransferComplete(const RequestT& /*request*/, const SnapshotT& /*snapshot*/) {}
38+
39+
/**
40+
* Invoked exactly once when the transfer fails or is cancelled.
41+
*/
42+
virtual void OnTransferFailed(const RequestT& /*request*/, const SnapshotT& /*snapshot*/) {}
43+
};
44+
45+
}
46+
}
47+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0.
4+
*/
5+
#pragma once
6+
#include <aws/s3-transfer/S3Transfer_EXPORTS.h>
7+
#include <cstdint>
8+
#include <memory>
9+
#include <utility>
10+
11+
namespace Aws {
12+
namespace S3 {
13+
namespace Transfer {
14+
15+
/**
16+
* Immutable snapshot of transfer progress passed to ProgressListener callbacks. Captures
17+
* bytes transferred, total bytes, and the response once available. Specialized via the
18+
* UploadProgressSnapshot and DownloadProgressSnapshot type aliases.
19+
*/
20+
template <typename ResponseT>
21+
class ProgressSnapshot {
22+
public:
23+
virtual ~ProgressSnapshot() = default;
24+
25+
ProgressSnapshot(uint64_t transferredBytes,
26+
uint64_t totalBytes,
27+
std::shared_ptr<ResponseT> response,
28+
bool totalBytesHasBeenSet)
29+
: m_transferredBytes(transferredBytes),
30+
m_totalBytes(totalBytes),
31+
m_response(std::move(response)),
32+
m_totalBytesHasBeenSet(totalBytesHasBeenSet) {}
33+
34+
inline uint64_t GetTransferredBytes() const { return m_transferredBytes; }
35+
inline uint64_t GetTotalBytes() const { return m_totalBytes; }
36+
inline bool TotalBytesHasBeenSet() const { return m_totalBytesHasBeenSet; }
37+
inline const std::shared_ptr<ResponseT>& GetResponse() const { return m_response; }
38+
inline bool ResponseHasBeenSet() const { return m_response != nullptr; }
39+
40+
private:
41+
uint64_t m_transferredBytes = 0;
42+
uint64_t m_totalBytes = 0;
43+
std::shared_ptr<ResponseT> m_response;
44+
bool m_totalBytesHasBeenSet = false;
45+
};
46+
47+
}
48+
}
49+
}

0 commit comments

Comments
 (0)