1 | initial version |
To create an S3 client using AWS SDK for Java 2.X, you can follow the below steps:
Maven:
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>s3</artifactId>
<version>2.16.73</version>
</dependency>
Gradle:
implementation 'software.amazon.awssdk:s3:2.16.73'
S3Client
class using the static builder()
method:S3Client s3Client = S3Client.builder()
.region(Region.US_EAST_1)
.build();
S3Client
instance to interact with S3. For example, you can list S3 buckets using the listBuckets()
method:ListBucketsResponse listBucketsResponse = s3Client.listBuckets();
listBucketsResponse.buckets().forEach(bucket -> System.out.println(bucket.name()));
close()
method:s3Client.close();