Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/main/java/com/example/aws/S3Manager.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
@Component
@RequiredArgsConstructor
public class S3Manager {

private final AmazonS3 amazonS3;
private final AmazonConfig awsConfig;
private final UuidRepository uuidRepository;
Expand All @@ -30,10 +31,10 @@ public String uploadFile(String keyName, MultipartFile file){
log.error("error at AmazonS3Manager uploadFile : {}", (Object) e.getStackTrace());
}

return amazonS3.getUrl(awsConfig.getBucket(), keyName).toString();}
return amazonS3.getUrl(awsConfig.getBucket(), keyName).toString();
}

public String generateReviewKeyName(Uuid uuid) {

return awsConfig.getReviewPath() + '/' + uuid.getUuid();
return awsConfig.getReviewPath() + "/" + uuid.getUuid();
}
}
27 changes: 12 additions & 15 deletions src/main/java/com/example/config/AmazonConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configurable
@Configuration
@Getter
public class AmazonConfig {

private AWSCredentials awsCredentials;

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

@Value("${cloud.aws.credentials.secret-key}")
@Value("${cloud.aws.credentials.secretKey}")
private String secretKey;

@Value("${cloud.aws.region.static}")
Expand All @@ -34,21 +35,17 @@ public class AmazonConfig {
private String reviewPath;

@PostConstruct
public void init() {
this.awsCredentials = new BasicAWSCredentials(accessKey, secretKey);
}
public void init() { this.awsCredentials = new BasicAWSCredentials(accessKey, secretKey); }

@Bean
public AmazonS3 amazonS3() {
AWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretKey);
return AmazonS3ClientBuilder.standard()
.withRegion(region)
.withCredentials(new AWSStaticCredentialsProvider(awsCredentials))
.build();
AWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretKey);
return AmazonS3ClientBuilder.standard()
.withRegion(region)
.withCredentials(new AWSStaticCredentialsProvider(awsCredentials))
.build();
}

@Bean
public AWSCredentialsProvider awsCredentialsProvider() {
return new AWSStaticCredentialsProvider(awsCredentials);
}
}
public AWSCredentialsProvider awsCredentialsProvider() { return new AWSStaticCredentialsProvider(awsCredentials); }
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
package com.example.service.store;

import com.example.aws.S3Manager;
import com.example.converter.ReviewConverter;
import com.example.domain.Review;
import com.example.domain.Uuid;
import com.example.repository.ReviewImageRepository;
import com.example.repository.ReviewRepository;
import com.example.repository.StoreRepository;
import com.example.repository.UuidRepository;
import com.example.service.member.MemberQueryService;
import jakarta.transaction.Transactional;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.util.UUID;

@Service
@RequiredArgsConstructor
Expand Down