Instructions for installing Amazon Simple Storage Service (S3) in Spring Boot

Tram Ho

Instructions for installing Amazon Simple Storage Service (S3) in Spring Boot

1. What is Amazon S3?

Amazon S3 is an object storage service built to store and retrieve data in any volume from anywhere on the Internet. This is a simple storage service that provides data storage infrastructure with extremely high durability, high availability and extremely flexible scale with very low cost.

2. Create S3 bucket

You access the following link to proceed to create the bucket

https://s3.console.aws.amazon.com/s3/home?region=us-west-2

Click create bucket

Enter the bucket and region names then select the config settings in the steps to complete the bucket creation

3. Install the environment before the code

To install the code in the project we need the following properties:

a. If running in a normal server environment or on your local machine:

b. If running in aws environment like EC2:

In this article I will guide you to run in the local environment to conduct tests offline.

Step 1: Get accessKey and secretKey

You go to My Security Credential

And proceed to create as usual. The result is an exported .csv file

Step 2: Install AWS Command Line Interface (CLI)

Link: https://aws.amazon.com/en/cli/

Like my computer is windows 64bit. I will download an .msi file and install it as usual

After installation, just with an aws –version command, you will check if you have installed it.

Step 3: Add secret key, access key, region, output format to aws configure

Go to Command Prompt, type aws configure command

And proceed to fill out the information

To view the region. You can see the list define here https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.RegionsAndAvailabilityZones.html

What about the output format. I choose to be json

4. Install the code in spring boot

Step 1:

Create a Spring Boot demo project

Step 2: Add the SDK

* ) The code file

Demo project structure:

* ) Files

a. application.yml

b. DemoApplication

c. StorageService

d. MediaController

* ) Postman run results

Call API upload image

Call API get image

So my share here is the end. Thank you for watching !!!

Share the news now

Source : Viblo