diff --git a/crt/aws-crt-cpp b/crt/aws-crt-cpp index b5577fa39c3..281a7caff7e 160000 --- a/crt/aws-crt-cpp +++ b/crt/aws-crt-cpp @@ -1 +1 @@ -Subproject commit b5577fa39c3a11f09c06db10ac6eaaca3910cbe2 +Subproject commit 281a7caff7e10f68a5422d8fca8acf0b48e4215f diff --git a/src/aws-cpp-sdk-core/source/http/curl/CurlHttpClient.cpp b/src/aws-cpp-sdk-core/source/http/curl/CurlHttpClient.cpp index abd0361945d..c9875f7e846 100644 --- a/src/aws-cpp-sdk-core/source/http/curl/CurlHttpClient.cpp +++ b/src/aws-cpp-sdk-core/source/http/curl/CurlHttpClient.cpp @@ -953,6 +953,7 @@ std::shared_ptr CurlHttpClient::MakeRequest(const std::shared_ptr< response->SetClientErrorMessage(ss.str()); AWS_LOGSTREAM_ERROR(CURL_HTTP_CLIENT_TAG, ss.str()); } + std::cout<<"curl transmission time="<<(DateTime::Now() - startTransmissionTime).count()<AddRequestMetric(GetHttpClientMetricNameByType(HttpClientMetricsType::RequestLatency), (DateTime::Now() - startTransmissionTime).count()); } diff --git a/tests/aws-cpp-sdk-s3-integration-tests/BucketAndObjectOperationTest.cpp b/tests/aws-cpp-sdk-s3-integration-tests/BucketAndObjectOperationTest.cpp index 3665ec3c8e5..c0e2267dc54 100644 --- a/tests/aws-cpp-sdk-s3-integration-tests/BucketAndObjectOperationTest.cpp +++ b/tests/aws-cpp-sdk-s3-integration-tests/BucketAndObjectOperationTest.cpp @@ -2580,4 +2580,63 @@ namespace AWS_EXPECT_SUCCESS(headOutcome); EXPECT_EQ(headOutcome.GetResult().GetContentEncoding(), "gzip"); } + + +void DownloadFile(const Aws::String& bucket_name, const Aws::String& object_key, const Aws::String& destination_file) +{ + auto Limiter = Aws::MakeShared>(ALLOCATION_TAG, 50000000); + + ClientConfiguration config; + config.region = Aws::Region::US_WEST_2; + config.scheme = Scheme::HTTPS; + config.connectTimeoutMs = 30000; + config.requestTimeoutMs = 30000; + config.readRateLimiter = Limiter; + config.writeRateLimiter = Limiter; + config.executor = Aws::MakeShared(ALLOCATION_TAG, 4); + config.enableHttpClientTrace = true; + + Aws::S3::S3Client s3_client(config); + + + // Open the destination file for writing + std::ofstream output_file(destination_file.c_str(), std::ios::binary); + + if (!output_file) { + std::cerr << "Failed to open destination file." << std::endl; + return; + } + + // Create a GetObjectRequest with the byte range + Aws::S3::Model::GetObjectRequest get_object_request; + get_object_request.SetBucket(bucket_name); + get_object_request.SetKey(object_key); + auto start = std::chrono::high_resolution_clock::now(); + auto get_object_outcome = s3_client.GetObject(get_object_request); + auto stop = std::chrono::high_resolution_clock::now(); + auto duration = std::chrono::duration_cast(stop - start); + + if (get_object_outcome.IsSuccess()) { + // Write the part to the destination file + auto& retrieved_file = get_object_outcome.GetResultWithOwnership().GetBody(); + std::ofstream output_file(destination_file, std::ios::binary); + output_file << retrieved_file.rdbuf(); // Write the stream content to the file + std::cout << "File downloaded to " << destination_file << std::endl; + + } else { + std::cerr << "Failed to download file: " << get_object_outcome.GetError().GetMessage() << std::endl; + } + + std::cout<<"took "<