4242import software .amazon .awssdk .awscore .AwsRequestOverrideConfiguration ;
4343import software .amazon .awssdk .awscore .retry .AwsRetryStrategy ;
4444import software .amazon .awssdk .core .SdkRequest ;
45+ import software .amazon .awssdk .core .async .AsyncResponseTransformer ;
4546import software .amazon .awssdk .core .checksums .ChecksumValidation ;
4647import software .amazon .awssdk .core .checksums .RequestChecksumCalculation ;
4748import software .amazon .awssdk .core .checksums .ResponseChecksumValidation ;
5758import software .amazon .awssdk .core .signer .NoOpSigner ;
5859import software .amazon .awssdk .crt .io .ExponentialBackoffRetryOptions ;
5960import software .amazon .awssdk .crt .io .StandardRetryOptions ;
61+ import software .amazon .awssdk .crt .s3 .S3MetaRequestOptions ;
6062import software .amazon .awssdk .http .SdkHttpExecutionAttributes ;
6163import software .amazon .awssdk .identity .spi .AwsCredentialsIdentity ;
6264import software .amazon .awssdk .identity .spi .IdentityProvider ;
7274import software .amazon .awssdk .services .s3 .internal .s3express .S3ExpressUtils ;
7375import software .amazon .awssdk .services .s3 .model .CopyObjectRequest ;
7476import software .amazon .awssdk .services .s3 .model .CopyObjectResponse ;
77+ import software .amazon .awssdk .services .s3 .model .GetObjectRequest ;
78+ import software .amazon .awssdk .services .s3 .model .GetObjectResponse ;
7579import software .amazon .awssdk .services .s3 .model .PutObjectRequest ;
7680import software .amazon .awssdk .services .s3 .model .PutObjectResponse ;
7781import software .amazon .awssdk .utils .CollectionUtils ;
8084@ SdkInternalApi
8185public final class DefaultS3CrtAsyncClient extends DelegatingS3AsyncClient implements S3CrtAsyncClient {
8286 public static final ExecutionAttribute <Path > OBJECT_FILE_PATH = new ExecutionAttribute <>("objectFilePath" );
87+ public static final ExecutionAttribute <Path > RESPONSE_FILE_PATH = new ExecutionAttribute <>("responseFilePath" );
88+ public static final ExecutionAttribute <S3MetaRequestOptions .ResponseFileOption > RESPONSE_FILE_OPTION =
89+ new ExecutionAttribute <>("responseFileOption" );
8390 private static final String CRT_CLIENT_CLASSPATH = "software.amazon.awssdk.crt.s3.S3Client" ;
8491 private final CopyObjectHelper copyObjectHelper ;
8592
@@ -106,6 +113,22 @@ public CompletableFuture<PutObjectResponse> putObject(PutObjectRequest putObject
106113 new CrtContentLengthOnlyAsyncFileRequestBody (sourcePath ));
107114 }
108115
116+ @ Override
117+ public CompletableFuture <GetObjectResponse > getObject (GetObjectRequest getObjectRequest , Path destinationPath ) {
118+ AsyncResponseTransformer <GetObjectResponse , GetObjectResponse > responseTransformer =
119+ new CrtResponseFileResponseTransformer <>();
120+
121+ AwsRequestOverrideConfiguration overrideConfig =
122+ getObjectRequest .overrideConfiguration ()
123+ .map (config -> config .toBuilder ().putExecutionAttribute (RESPONSE_FILE_PATH , destinationPath ))
124+ .orElseGet (() -> AwsRequestOverrideConfiguration .builder ()
125+ .putExecutionAttribute (RESPONSE_FILE_PATH ,
126+ destinationPath ))
127+ .build ();
128+
129+ return getObject (getObjectRequest .toBuilder ().overrideConfiguration (overrideConfig ).build (), responseTransformer );
130+ }
131+
109132 @ Override
110133 public CompletableFuture <CopyObjectResponse > copyObject (CopyObjectRequest copyObjectRequest ) {
111134 return copyObjectHelper .copyObject (copyObjectRequest );
@@ -243,7 +266,7 @@ public DefaultS3CrtClientBuilder credentialsProvider(AwsCredentialsProvider cred
243266
244267 @ Override
245268 public DefaultS3CrtClientBuilder credentialsProvider (
246- IdentityProvider <? extends AwsCredentialsIdentity > credentialsProvider ) {
269+ IdentityProvider <? extends AwsCredentialsIdentity > credentialsProvider ) {
247270 this .credentialsProvider = credentialsProvider ;
248271 return this ;
249272 }
@@ -396,6 +419,10 @@ public void afterMarshalling(Context.AfterMarshalling context,
396419 executionAttributes .getAttribute (SdkInternalExecutionAttribute .REQUEST_CHECKSUM_CALCULATION ))
397420 .put (RESPONSE_CHECKSUM_VALIDATION ,
398421 executionAttributes .getAttribute (SdkInternalExecutionAttribute .RESPONSE_CHECKSUM_VALIDATION ))
422+ .put (S3InternalSdkHttpExecutionAttribute .RESPONSE_FILE_PATH ,
423+ executionAttributes .getAttribute (RESPONSE_FILE_PATH ))
424+ .put (S3InternalSdkHttpExecutionAttribute .RESPONSE_FILE_OPTION ,
425+ executionAttributes .getAttribute (RESPONSE_FILE_OPTION ))
399426 .build ();
400427
401428 // We rely on CRT to perform checksum validation, disable SDK flexible checksum implementation
0 commit comments