Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake/sdks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions cmake/sdksCommon.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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")
Expand Down
61 changes: 61 additions & 0 deletions src/aws-cpp-sdk-s3-transfer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
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()
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/s3-transfer/S3Transfer_EXPORTS.h>
#include <future>
#include <memory>
#include <aws/s3-transfer/DownloadResponse.h>


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 {
public:
~DownloadHandle();

/**
* Returns a future that resolves once the transfer finishes, succeeds, or fails.
*/
std::shared_future<DownloadResponse> CompletionFuture() const;

/**
* 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:
std::shared_ptr<DownloadHandleImpl> m_impl;
};


}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/s3-transfer/S3Transfer_EXPORTS.h>

namespace Aws {
namespace S3 {
namespace Transfer {

class DownloadRequest;
class DownloadProgressSnapshot;

/**
* 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:
virtual ~DownloadProgressListener() = default;

/**
* Invoked exactly once when the download begins, before any bytes have been transferred.
*/
virtual void OnTransferInitiated(const DownloadRequest&, const DownloadProgressSnapshot&) {}

/**
* Invoked as bytes are received from S3. 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 DownloadRequest&, const DownloadProgressSnapshot&) {}

/**
* Invoked exactly once when the download completes successfully.
*/
virtual void OnTransferComplete(const DownloadRequest&, const DownloadProgressSnapshot&) {}

/**
* Invoked exactly once when the download fails or is cancelled.
*/
virtual void OnTransferFailed(const DownloadRequest&, const DownloadProgressSnapshot&) {}
};

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/s3-transfer/S3Transfer_EXPORTS.h>
#include <aws/s3-transfer/DownloadResponse.h>
#include <cstdint>
#include <memory>
#include <utility>

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 {
public:
DownloadProgressSnapshot(uint64_t transferredBytes,
uint64_t totalBytes,
std::shared_ptr<DownloadResponse> 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<DownloadResponse>& 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<DownloadResponse> m_response;
bool m_totalBytesHasBeenSet = false;
};

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/s3-transfer/S3Transfer_EXPORTS.h>
#include <aws/s3-transfer/DownloadProgressListener.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/core/utils/memory/stl/AWSVector.h>
#include <aws/core/utils/stream/ResponseStream.h>
#include <aws/s3/model/GetObjectRequest.h>
#include <memory>
#include <utility>

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 {
public:
inline const Aws::S3::Model::GetObjectRequest& GetS3Request() const { return m_s3Request; }
inline bool S3RequestHasBeenSet() const { return m_s3RequestHasBeenSet; }
template <typename S3RequestT = Aws::S3::Model::GetObjectRequest>
void SetS3Request(S3RequestT&& val) {
m_s3RequestHasBeenSet = true;
m_s3Request = std::forward<S3RequestT>(val);
}
template <typename S3RequestT = Aws::S3::Model::GetObjectRequest>
DownloadRequest& WithS3Request(S3RequestT&& value) {
SetS3Request(std::forward<S3RequestT>(value));
return *this;
}

inline const Aws::String& GetDestinationFilePath() const { return m_destinationFilePath; }
inline bool DestinationFilePathHasBeenSet() const { return m_destinationFilePathHasBeenSet; }
template <typename DestinationFilePathT = Aws::String>
void SetDestinationFilePath(DestinationFilePathT&& value) {
m_destinationFilePathHasBeenSet = true;
m_destinationFilePath = std::forward<DestinationFilePathT>(value);
}
template <typename DestinationFilePathT = Aws::String>
DownloadRequest& WithDestinationFilePath(DestinationFilePathT&& value) {
SetDestinationFilePath(std::forward<DestinationFilePathT>(value));
return *this;
}

inline const Aws::IOStreamFactory& GetBody() const { return m_body; }
inline bool BodyHasBeenSet() const { return m_bodyHasBeenSet; }
inline void SetBody(const Aws::IOStreamFactory& val) {
m_bodyHasBeenSet = true;
m_body = val;
}
inline DownloadRequest& WithBody(const Aws::IOStreamFactory& val) {
SetBody(val);
return *this;
}

inline const Aws::Vector<std::shared_ptr<DownloadProgressListener>>& GetTransferListeners() const {
return m_transferListeners;
}
inline bool TransferListenersHasBeenSet() const { return m_transferListenersHasBeenSet; }
inline void SetTransferListeners(const Aws::Vector<std::shared_ptr<DownloadProgressListener>>& val) {
m_transferListenersHasBeenSet = true;
m_transferListeners = val;
}
inline DownloadRequest& WithTransferListeners(const Aws::Vector<std::shared_ptr<DownloadProgressListener>>& val) {
SetTransferListeners(val);
return *this;
}
inline DownloadRequest& AddTransferListener(const std::shared_ptr<DownloadProgressListener>& listener) {
m_transferListenersHasBeenSet = true;
m_transferListeners.push_back(listener);
return *this;
}

private:
Aws::S3::Model::GetObjectRequest m_s3Request;
Aws::String m_destinationFilePath;
Aws::IOStreamFactory m_body;
Aws::Vector<std::shared_ptr<DownloadProgressListener>> m_transferListeners;
bool m_s3RequestHasBeenSet = false;
bool m_destinationFilePathHasBeenSet = false;
bool m_bodyHasBeenSet = false;
bool m_transferListenersHasBeenSet = false;
};

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/s3-transfer/S3Transfer_EXPORTS.h>
#include <aws/s3/model/GetObjectResult.h>
#include <utility>

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 {
public:
inline const Aws::S3::Model::GetObjectResult& GetS3Result() const { return m_s3Result; }
inline bool S3ResultHasBeenSet() const { return m_s3ResultHasBeenSet; }
template <typename GetObjectResultT = Aws::S3::Model::GetObjectResult>
void SetS3Result(GetObjectResultT&& getS3Result) {
m_s3ResultHasBeenSet = true;
m_s3Result = std::forward<GetObjectResultT>(getS3Result);
}
template <typename GetObjectResultT = Aws::S3::Model::GetObjectResult>
DownloadResponse& WithS3Result(GetObjectResultT&& getS3Result) {
SetS3Result(std::forward<GetObjectResultT>(getS3Result));
return *this;
}

private:
Aws::S3::Model::GetObjectResult m_s3Result;
bool m_s3ResultHasBeenSet = false;
};

}
}
}
Loading
Loading