Skip to content

Commit

Permalink
feat: [kakao-tech-campus-2nd-step3#30] S3Config 파일 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
jupyter471 committed Oct 11, 2024
1 parent 302c85b commit 6de5081
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/main/java/com/helpmeCookies/global/config/S3Config.java
Original file line number Diff line number Diff line change
@@ -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();
}
}

0 comments on commit 6de5081

Please sign in to comment.