Upload files to Amazon S3 via AWS SDK for Java 2.x using SpringBoot
Follow the below instructions to get started with the source code:
- Make sure you have all Requirements
- Make sure to add AWS SDK for Java 2.x
- Configure storage properties
-
IAM user with access-key and secret-access-key (user’s credentials)
-
Summary of Process done in AWS
- AWS Java SDK Amazon S3:
<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>s3</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.17.124</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
amazon.s3.bucket-name = ${AMAZON_S3_BUCKET_NAME}
amazon.s3.region = ${AWS_DEFAULT_REGION}
amazon.aws.credentials.access-key = ${AWS_ACCESS_KEY_ID}
amazon.aws.credentials.secret-access-key = ${AWS_SECRET_ACCESS_KEY}
In case of yaml
spring:
profiles:
active: ${CONFIG_PROFILE:uat}