Skip to content

Commit

Permalink
Merge branch 'develop' into chore/393-nginx-workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
char-yb authored May 16, 2024
2 parents 3935c1c + fd3649a commit a4298f2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -62,7 +62,7 @@ public PresignedUrlResponse createMissionRecordPresignedUrl(
request.imageFileExtension());
GeneratePresignedUrlRequest generatePresignedUrlRequest =
createGeneratePreSignedUrlRequest(
storageProperties.bucket(),
s3Properties.bucket(),
fileName,
request.imageFileExtension().getUploadExtension());

Expand Down Expand Up @@ -113,7 +113,7 @@ public PresignedUrlResponse createMemberProfilePresignedUrl(
request.imageFileExtension());
GeneratePresignedUrlRequest generatePresignedUrlRequest =
createGeneratePreSignedUrlRequest(
storageProperties.bucket(),
s3Properties.bucket(),
fileName,
request.imageFileExtension().getUploadExtension());

Expand Down Expand Up @@ -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()
+ "/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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) {}
10 changes: 5 additions & 5 deletions src/main/resources/application-storage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}

0 comments on commit a4298f2

Please sign in to comment.