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
19 changes: 13 additions & 6 deletions src/main/java/kr/co/amateurs/server/config/S3Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,32 @@
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.S3Configuration;

import java.net.URI;

@Configuration
public class S3Config {

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

@Value("${cloudflare.r2.access-key}")
private String accessKey;

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

@Value("${cloud.aws.region.static}")
private String region;

@Bean
public S3Client s3Client() {
AwsBasicCredentials credentials = AwsBasicCredentials.create(accessKey, secretKey);
return S3Client.builder()
.region(Region.of(region))
.endpointOverride(URI.create(endpoint))
.region(Region.of("auto"))
.credentialsProvider(StaticCredentialsProvider.create(credentials))
.serviceConfiguration(S3Configuration.builder()
.pathStyleAccessEnabled(true)
.build())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
@RequiredArgsConstructor
public class FileService {

@Value("${cloud.aws.cloudfront.domain}")
@Value("${cloudflare.r2.public-url}")
public String publicUrl;

@Value("${cloud.aws.s3.bucket}")
@Value("${cloudflare.r2.bucket}")
private String bucket;

private final S3Client s3Client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public class UnreferencedImageClearScheduler {
private final PostImageRepository postImageRepository;
private final FileService fileService;

@Value("${cloud.aws.cloudfront.domain}")
@Value("${cloudflare.r2.public-url}")
public String publicUrl;

@Value("${cloud.aws.s3.bucket}")
@Value("${cloudflare.r2.bucket}")
private String bucket;

// 한번에 처리할 작업의 크기(메모리 오버 대비)
Expand Down
22 changes: 9 additions & 13 deletions src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,6 @@ jwt:
access-token-expiration-ms: 3600000
refresh-token-expiration-ms: 1209600000

cloud:
aws:
credentials:
access-key: ${AWS_ACCESS_KEY}
secret_key: ${AWS_SECRET_KEY}
region:
static: ${S3_REGION}
s3:
bucket: ${S3_BUCKET_NAME}
cloudfront:
domain: ${CLOUD_FRONT_DOMAIN_NAME}

management:
endpoints:
web:
Expand Down Expand Up @@ -135,4 +123,12 @@ otel:
metrics:
exporter: none
logs:
exporter: none
exporter: none

cloudflare:
r2:
endpoint: ${CLOUDFLARE_R2_ENDPOINT}
access-key: ${CLOUDFLARE_R2_ACCESS_KEY}
secret-key: ${CLOUDFLARE_R2_SECRET_KEY}
bucket: ${CLOUDFLARE_R2_BUCKET}
public-url: ${CLOUDFLARE_R2_PUBLIC_URL}
22 changes: 9 additions & 13 deletions src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,6 @@ jwt:
access-token-expiration-ms: 3600000
refresh-token-expiration-ms: 1209600000

cloud:
aws:
credentials:
access-key: ${AWS_ACCESS_KEY}
secret_key: ${AWS_SECRET_KEY}
region:
static: ${S3_REGION}
s3:
bucket: ${S3_BUCKET_NAME}
cloudfront:
domain: ${CLOUD_FRONT_DOMAIN_NAME}

oauth:
success-redirect-url: http://localhost:5173

Expand All @@ -138,4 +126,12 @@ otel:
metrics:
exporter: none
logs:
exporter: none
exporter: none

cloudflare:
r2:
endpoint: ${CLOUDFLARE_R2_ENDPOINT}
access-key: ${CLOUDFLARE_R2_ACCESS_KEY}
secret-key: ${CLOUDFLARE_R2_SECRET_KEY}
bucket: ${CLOUDFLARE_R2_BUCKET}
public-url: ${CLOUDFLARE_R2_PUBLIC_URL}
20 changes: 8 additions & 12 deletions src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,6 @@ jwt:
access-token-expiration-ms: 3600000
refresh-token-expiration-ms: 1209600000

cloud:
aws:
credentials:
access-key: ${AWS_ACCESS_KEY}
secret_key: ${AWS_SECRET_KEY}
region:
static: ${S3_REGION}
s3:
bucket: ${S3_BUCKET_NAME}
cloudfront:
domain: ${CLOUD_FRONT_DOMAIN_NAME}

management:
endpoints:
web:
Expand Down Expand Up @@ -173,3 +161,11 @@ otel:
endpoint: ${OTEL_COLLECTOR_URL}
compression: gzip
timeout: 10s

cloudflare:
r2:
endpoint: ${CLOUDFLARE_R2_ENDPOINT}
access-key: ${CLOUDFLARE_R2_ACCESS_KEY}
secret-key: ${CLOUDFLARE_R2_SECRET_KEY}
bucket: ${CLOUDFLARE_R2_BUCKET}
public-url: ${CLOUDFLARE_R2_PUBLIC_URL}
22 changes: 9 additions & 13 deletions src/test/resources/application-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,6 @@ jwt:
access-token-expiration-ms: 3600000
refresh-token-expiration-ms: 1209600000

cloud:
aws:
credentials:
access-key: testAccessKey
secret_key: testSecretKey
region:
static: test-region
s3:
bucket: test-bucket-name
cloudfront:
domain: testdomain.net

de:
flapdoodle:
mongodb:
Expand All @@ -100,4 +88,12 @@ app:

verification:
service:
url: http://localhost:5000/verify/url
url: http://localhost:5000/verify/url

cloudflare:
r2:
endpoint: http://test-endpoint
access-key: test-access-key
secret-key: test-secret-key
bucket: test-bucket
public-url: test-public-url
Loading