From 6de5081e542a9f2b238262345794d1fc1c2b62d8 Mon Sep 17 00:00:00 2001 From: bokyeong Date: Fri, 11 Oct 2024 23:28:58 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20[#30]=20S3Config=20=ED=8C=8C=EC=9D=BC?= =?UTF-8?q?=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../helpmeCookies/global/config/S3Config.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/java/com/helpmeCookies/global/config/S3Config.java diff --git a/src/main/java/com/helpmeCookies/global/config/S3Config.java b/src/main/java/com/helpmeCookies/global/config/S3Config.java new file mode 100644 index 0000000..e4df773 --- /dev/null +++ b/src/main/java/com/helpmeCookies/global/config/S3Config.java @@ -0,0 +1,29 @@ +package com.helpmeCookies.global.config; + +import com.amazonaws.auth.AWSCredentials; +import com.amazonaws.auth.AWSStaticCredentialsProvider; +import com.amazonaws.auth.BasicAWSCredentials; +import com.amazonaws.services.s3.AmazonS3; +import com.amazonaws.services.s3.AmazonS3ClientBuilder; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class S3Config { + @Value("${cloud.aws.credentials.access-key}") + private String accessKey; + @Value("${cloud.aws.credentials.secret-key}") + private String secretKey; + @Value("${cloud.aws.region.static}") + private String region; + + public AmazonS3 amazonS3() { + AWSCredentials credentials = new BasicAWSCredentials(accessKey,secretKey); + + return AmazonS3ClientBuilder + .standard() + .withCredentials(new AWSStaticCredentialsProvider(credentials)) + .withRegion(region) + .build(); + } +}