How to enable Multipart PutObject request using java AWS CRT-based S3 client?

119 views Asked by At

I'm using the new AWS CRT-based S3 client that should automatically use Amazon S3's multipart upload API. (cf : https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/crt-based-s3-client.html).

However, looking at the execution pile, the delegated async client created by the .crtBuilder() method is always a DefaultS3AsyncClient but never a MultipartS3AsyncClient. Hence, it doesn't perform Multipart PutObject.

S3AsyncClient s3AsyncClient = S3AsyncClient
                .crtBuilder()
                .endpointOverride(endpointUrl)
                .credentialsProvider(() -> awsCredentials)
                .region(Region.of(region))
                .forcePathStyle(true)
                .build();

PutObjectRequest request = PutObjectRequest.builder()
        .bucket(bucketName)
        .key(key)
        .build();

CompletableFuture<PutObjectResponse> putResponse = s3AsyncClient.putObject(
        request,
        AsyncRequestBody.fromInputStream(multiPartfile.getInputStream(), multiPartfile.getSize(), Executors.newFixedThreadPool(2))
);

Can you explain if this is the expected behaviour and how to perform multipart put request using these "high-level" API AWS CRT-based S3 client or S3TransferManager?

0

There are 0 answers