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();
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-05-13 23:32:46 +0000
Seen: 9 times
Last updated: May 13 '23
What are the typical approaches found in a Gradle build script?
What steps can be taken to increase the runtime of a debugger in NativeScript?
What is the method to show the dependencies in Java?
How can I incorporate BeanComparator into my gradle project?
What does the "Invalid source release 1.7" error mean when using gradle for compilation?