Skip to content

Commit

Permalink
add progress callback for s3crt (#2881)
Browse files Browse the repository at this point in the history
* add progress callback for s3crt

* change name to progressHandler
  • Loading branch information
jmklix authored Mar 4, 2024
1 parent 2439d5a commit 612dc7a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions generated/src/aws-cpp-sdk-s3-crt/source/S3CrtClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,21 @@ static int S3CrtRequestGetBodyCallback(struct aws_s3_meta_request *meta_request,
return AWS_OP_SUCCESS;
}

static void S3CrtRequestProgressCallback(struct aws_s3_meta_request *meta_request, const struct aws_s3_meta_request_progress *progress, void *user_data)
{
AWS_UNREFERENCED_PARAM(meta_request);
auto *userData = static_cast<S3CrtClient::CrtRequestCallbackUserData*>(user_data);

auto& progressHandler = userData->request->GetDataSentEventHandler();
if (progressHandler)
{
progressHandler(userData->request.get(), static_cast<long long>(progress->bytes_transferred));
}
AWS_LOGSTREAM_TRACE(ALLOCATION_TAG, progress->bytes_transferred << " bytes transferred.");

return;
}

static void S3CrtRequestFinishCallback(struct aws_s3_meta_request *meta_request,
const struct aws_s3_meta_request_result *meta_request_result, void *user_data)
{
Expand Down Expand Up @@ -685,6 +700,7 @@ void S3CrtClient::InitCommonCrtRequestOption(CrtRequestCallbackUserData *userDat
options->user_data = static_cast<void*>(userData);
options->headers_callback = S3CrtRequestHeadersCallback;
options->body_callback = S3CrtRequestGetBodyCallback;
options->progress_callback = S3CrtRequestProgressCallback;
options->finish_callback = S3CrtRequestFinishCallback;
const auto endpointStr = uri.GetURIString();
const auto endpointCursor{ aws_byte_cursor_from_array(endpointStr.c_str(), endpointStr.size()) };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ static int S3CrtRequestGetBodyCallback(struct aws_s3_meta_request *meta_request,
return AWS_OP_SUCCESS;
}

static void S3CrtRequestProgressCallback(struct aws_s3_meta_request *meta_request, const struct aws_s3_meta_request_progress *progress, void *user_data)
{
AWS_UNREFERENCED_PARAM(meta_request);
auto *userData = static_cast<S3CrtClient::CrtRequestCallbackUserData*>(user_data);

auto& progressHandler = userData->request->GetDataSentEventHandler();
if (progressHandler)
{
progressHandler(userData->request.get(), static_cast<long long>(progress->bytes_transferred));
}
AWS_LOGSTREAM_TRACE(ALLOCATION_TAG, progress->bytes_transferred << " bytes transferred.");

return;
}

static void S3CrtRequestFinishCallback(struct aws_s3_meta_request *meta_request,
const struct aws_s3_meta_request_result *meta_request_result, void *user_data)
{
Expand Down Expand Up @@ -183,6 +198,7 @@ void S3CrtClient::InitCommonCrtRequestOption(CrtRequestCallbackUserData *userDat
options->user_data = static_cast<void*>(userData);
options->headers_callback = S3CrtRequestHeadersCallback;
options->body_callback = S3CrtRequestGetBodyCallback;
options->progress_callback = S3CrtRequestProgressCallback;
options->finish_callback = S3CrtRequestFinishCallback;
const auto endpointStr = uri.GetURIString();
const auto endpointCursor{ aws_byte_cursor_from_array(endpointStr.c_str(), endpointStr.size()) };
Expand Down

0 comments on commit 612dc7a

Please sign in to comment.