Skip to content

Commit

Permalink
[feat] #1 S3 버켓 설정파일 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
dyk-im committed Jan 8, 2025
1 parent 982bd40 commit 55eae1b
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/main/java/com/wedit/weditapp/global/config/AwsConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.wedit.weditapp.global.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;

@Configuration
public class AwsConfig {
@Value("${cloud.aws.credentials.access-key}")
private String accessKey;

// S3를 등록한 사람이 전달받은 접속하기 위한 secret key 값
@Value("${cloud.aws.credentials.secret-key}")
private String secretKey;

// S3를 등록한 사람이 S3를 사용할 지역
@Value("${cloud.aws.region.static}")
private String region;

// 전달받은 Accesskey 와 SecretKey 로 아마존 서비스 실행 준비
@Bean
public AmazonS3Client amazonS3Client() {
BasicAWSCredentials awsCreds = new BasicAWSCredentials(accessKey, secretKey);
return (AmazonS3Client)AmazonS3ClientBuilder.standard()
.withRegion(region)
.withCredentials(new AWSStaticCredentialsProvider(awsCreds))
.build();
}
}

0 comments on commit 55eae1b

Please sign in to comment.