diff --git a/src/main/java/com/depromeet/domain/image/application/ImageService.java b/src/main/java/com/depromeet/domain/image/application/ImageService.java index 9f771f66a..bbe6daa74 100644 --- a/src/main/java/com/depromeet/domain/image/application/ImageService.java +++ b/src/main/java/com/depromeet/domain/image/application/ImageService.java @@ -25,7 +25,7 @@ import com.depromeet.global.error.exception.ErrorCode; import com.depromeet.global.util.MemberUtil; import com.depromeet.global.util.SpringEnvironmentUtil; -import com.depromeet.infra.config.storage.StorageProperties; +import com.depromeet.infra.config.s3.S3Properties; import java.util.Date; import java.util.UUID; import lombok.RequiredArgsConstructor; @@ -38,7 +38,7 @@ public class ImageService { private final MemberUtil memberUtil; private final SpringEnvironmentUtil springEnvironmentUtil; - private final StorageProperties storageProperties; + private final S3Properties s3Properties; private final AmazonS3 amazonS3; private final MissionRecordRepository missionRecordRepository; private final MissionRecordTtlRepository missionRecordTtlRepository; @@ -62,7 +62,7 @@ public PresignedUrlResponse createMissionRecordPresignedUrl( request.imageFileExtension()); GeneratePresignedUrlRequest generatePresignedUrlRequest = createGeneratePreSignedUrlRequest( - storageProperties.bucket(), + s3Properties.bucket(), fileName, request.imageFileExtension().getUploadExtension()); @@ -113,7 +113,7 @@ public PresignedUrlResponse createMemberProfilePresignedUrl( request.imageFileExtension()); GeneratePresignedUrlRequest generatePresignedUrlRequest = createGeneratePreSignedUrlRequest( - storageProperties.bucket(), + s3Properties.bucket(), fileName, request.imageFileExtension().getUploadExtension()); @@ -205,9 +205,9 @@ private String createUploadImageUrl( Long targetId, String imageKey, ImageFileExtension imageFileExtension) { - return storageProperties.endpoint() + return s3Properties.endpoint() + "/" - + storageProperties.bucket() + + s3Properties.bucket() + "/" + springEnvironmentUtil.getCurrentProfile() + "/" diff --git a/src/main/java/com/depromeet/infra/config/properties/PropertiesConfig.java b/src/main/java/com/depromeet/infra/config/properties/PropertiesConfig.java index c94e19f16..dfbb85699 100644 --- a/src/main/java/com/depromeet/infra/config/properties/PropertiesConfig.java +++ b/src/main/java/com/depromeet/infra/config/properties/PropertiesConfig.java @@ -3,12 +3,12 @@ import com.depromeet.infra.config.jwt.JwtProperties; import com.depromeet.infra.config.oidc.OidcProperties; import com.depromeet.infra.config.redis.RedisProperties; -import com.depromeet.infra.config.storage.StorageProperties; +import com.depromeet.infra.config.s3.S3Properties; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Configuration; @EnableConfigurationProperties({ - StorageProperties.class, + S3Properties.class, RedisProperties.class, JwtProperties.class, OidcProperties.class diff --git a/src/main/java/com/depromeet/infra/config/storage/StorageConfig.java b/src/main/java/com/depromeet/infra/config/s3/S3Config.java similarity index 73% rename from src/main/java/com/depromeet/infra/config/storage/StorageConfig.java rename to src/main/java/com/depromeet/infra/config/s3/S3Config.java index 29b549694..98e8a6823 100644 --- a/src/main/java/com/depromeet/infra/config/storage/StorageConfig.java +++ b/src/main/java/com/depromeet/infra/config/s3/S3Config.java @@ -1,4 +1,4 @@ -package com.depromeet.infra.config.storage; +package com.depromeet.infra.config.s3; import com.amazonaws.auth.AWSCredentials; import com.amazonaws.auth.AWSStaticCredentialsProvider; @@ -12,17 +12,16 @@ @Configuration @RequiredArgsConstructor -public class StorageConfig { - private final StorageProperties storageProperties; +public class S3Config { + private final S3Properties s3Properties; @Bean public AmazonS3 amazonS3() { AWSCredentials credentials = - new BasicAWSCredentials( - storageProperties.accessKey(), storageProperties.secretKey()); + new BasicAWSCredentials(s3Properties.accessKey(), s3Properties.secretKey()); AwsClientBuilder.EndpointConfiguration endpointConfiguration = new AwsClientBuilder.EndpointConfiguration( - storageProperties.endpoint(), storageProperties.region()); + s3Properties.endpoint(), s3Properties.region()); return AmazonS3ClientBuilder.standard() .withEndpointConfiguration(endpointConfiguration) diff --git a/src/main/java/com/depromeet/infra/config/storage/StorageProperties.java b/src/main/java/com/depromeet/infra/config/s3/S3Properties.java similarity index 73% rename from src/main/java/com/depromeet/infra/config/storage/StorageProperties.java rename to src/main/java/com/depromeet/infra/config/s3/S3Properties.java index 229e6fa82..ef15697f6 100644 --- a/src/main/java/com/depromeet/infra/config/storage/StorageProperties.java +++ b/src/main/java/com/depromeet/infra/config/s3/S3Properties.java @@ -1,7 +1,7 @@ -package com.depromeet.infra.config.storage; +package com.depromeet.infra.config.s3; import org.springframework.boot.context.properties.ConfigurationProperties; @ConfigurationProperties(prefix = "storage") -public record StorageProperties( +public record S3Properties( String accessKey, String secretKey, String region, String bucket, String endpoint) {} diff --git a/src/main/resources/application-storage.yml b/src/main/resources/application-storage.yml index eb57092c4..7556a10a7 100644 --- a/src/main/resources/application-storage.yml +++ b/src/main/resources/application-storage.yml @@ -3,8 +3,8 @@ spring: activate: on-profile: "storage" storage: - accessKey: ${STORAGE_ACCESS_KEY:} - secretKey: ${STORAGE_SECRET_KEY:} - bucket: ${STORAGE_BUCKET:} - region: ${STORAGE_REGION:} - endpoint: ${STORAGE_ENDPOINT:https://kr.object.ncloudstorage.com} + accessKey: ${AWS_ACCESS_KEY:} + secretKey: ${AWS_SECRET_KEY:} + bucket: ${S3_BUCKET:} + region: ${AWS_REGION:} + endpoint: ${S3_ENDPOINT:https://s3.ap-northeast-2.amazonaws.com}