Skip to content
Open
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,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 <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 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<DownloadOutcome> 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<DownloadHandleImpl> m_impl;
};


}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* 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/ProgressListener.h>
#include <aws/s3-transfer/DownloadProgressSnapshot.h>

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<DownloadRequest, DownloadProgressSnapshot> {};

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* 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/ProgressSnapshot.h>
#include <aws/s3-transfer/DownloadResponse.h>

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<DownloadResponse> {
public:
using ProgressSnapshot<DownloadResponse>::ProgressSnapshot;
};

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* 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 final {
public:
explicit DownloadRequest(
Aws::S3::Model::GetObjectRequest s3Request,
Aws::String destinationFilePath,
Aws::IOStreamFactory responseStreamFactory,
Aws::Vector<std::shared_ptr<DownloadProgressListener>> 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<std::shared_ptr<DownloadProgressListener>>& GetTransferListeners() const {
return m_transferListeners;
}


private:
Aws::S3::Model::GetObjectRequest m_s3Request;
Aws::String m_destinationFilePath;
Aws::IOStreamFactory m_responseStreamFactory;
Aws::Vector<std::shared_ptr<DownloadProgressListener>> m_transferListeners;
};

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* 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/core/client/AWSError.h>
#include <aws/core/utils/Outcome.h>
#include <aws/s3/S3Errors.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 final {
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;
};

using DownloadOutcome = Aws::Utils::Outcome<DownloadResponse, Aws::Client::AWSError<Aws::S3::S3Errors>>;

}
}
}
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>

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 <typename RequestT, typename SnapshotT>
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*/) {}
};

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* 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 <cstdint>
#include <memory>
#include <utility>

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 <typename ResponseT>
class ProgressSnapshot {
public:
virtual ~ProgressSnapshot() = default;

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

}
}
}
Loading
Loading