Skip to content

Commit

Permalink
feat : s3정보를 환경변수를 통해 가져오도록 설정 (CC-90)
Browse files Browse the repository at this point in the history
  • Loading branch information
j2noo committed Jul 30, 2024
1 parent 9b9a3cc commit 8a3e444
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src/main/java/ai/softeer/caecae/global/config/S3Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
@RequiredArgsConstructor
public class S3Config {

//TODO : 환경변수로 관리
// @Value("${cloud.aws.region.static}")
private String region = "ap-northeast-2";
@Value("${spring.region.static}")
private String region;


@Bean
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/ai/softeer/caecae/global/utils/S3Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
public class S3Service {
private final AmazonS3 amazonS3;

//TODO : 환경변수로 관리
// @Value("${cloud.aws.s3.bucket}")
private String bucket = "caecae-bucket";
@Value("${spring.s3.bucket}")
private String bucket;


/**
* S3에 파일을 업로드 하는 서비스 로직
*
* @param file
* @return 파일 이름
*/
Expand All @@ -44,12 +44,12 @@ public String uploadFile(MultipartFile file) {
// .withCannedAcl(CannedAccessControlList.PublicRead));

// 올린 오브젝트에 대한 s3 url
filePath = amazonS3.getUrl(bucket, fileName).toString();
filePath = amazonS3.getUrl(bucket, fileName).toString();
} catch (IOException e) {
throw new IllegalArgumentException("파일이 없습니다.");
//TODO : 커스텀 에러 관리하기
}
log.info(filePath," is successfully created in S3");
log.info(filePath, " is successfully created in S3");
return filePath;
}

Expand Down

0 comments on commit 8a3e444

Please sign in to comment.