File tree Expand file tree Collapse file tree
java/kr/co/amateurs/server Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88import software .amazon .awssdk .auth .credentials .StaticCredentialsProvider ;
99import software .amazon .awssdk .regions .Region ;
1010import software .amazon .awssdk .services .s3 .S3Client ;
11+ import software .amazon .awssdk .services .s3 .S3Configuration ;
12+
13+ import java .net .URI ;
1114
1215@ Configuration
1316public class S3Config {
1417
15- @ Value ("${cloud.aws.credentials.access-key}" )
18+ @ Value ("${cloudflare.r2.endpoint}" )
19+ private String endpoint ;
20+
21+ @ Value ("${cloudflare.r2.access-key}" )
1622 private String accessKey ;
1723
18- @ Value ("${cloud.aws.credentials .secret-key}" )
24+ @ Value ("${cloudflare.r2 .secret-key}" )
1925 private String secretKey ;
2026
21- @ Value ("${cloud.aws.region.static}" )
22- private String region ;
23-
2427 @ Bean
2528 public S3Client s3Client () {
2629 AwsBasicCredentials credentials = AwsBasicCredentials .create (accessKey , secretKey );
2730 return S3Client .builder ()
28- .region (Region .of (region ))
31+ .endpointOverride (URI .create (endpoint ))
32+ .region (Region .of ("auto" ))
2933 .credentialsProvider (StaticCredentialsProvider .create (credentials ))
34+ .serviceConfiguration (S3Configuration .builder ()
35+ .pathStyleAccessEnabled (true )
36+ .build ())
3037 .build ();
3138 }
3239}
Original file line number Diff line number Diff line change 3636@ RequiredArgsConstructor
3737public class FileService {
3838
39- @ Value ("${cloud.aws.cloudfront.domain }" )
39+ @ Value ("${cloudflare.r2.public-url }" )
4040 public String publicUrl ;
4141
42- @ Value ("${cloud.aws.s3 .bucket}" )
42+ @ Value ("${cloudflare.r2 .bucket}" )
4343 private String bucket ;
4444
4545 private final S3Client s3Client ;
Original file line number Diff line number Diff line change @@ -23,10 +23,10 @@ public class UnreferencedImageClearScheduler {
2323 private final PostImageRepository postImageRepository ;
2424 private final FileService fileService ;
2525
26- @ Value ("${cloud.aws.cloudfront.domain }" )
26+ @ Value ("${cloudflare.r2.public-url }" )
2727 public String publicUrl ;
2828
29- @ Value ("${cloud.aws.s3 .bucket}" )
29+ @ Value ("${cloudflare.r2 .bucket}" )
3030 private String bucket ;
3131
3232 // 한번에 처리할 작업의 크기(메모리 오버 대비)
Original file line number Diff line number Diff line change 8888 access-token-expiration-ms : 3600000
8989 refresh-token-expiration-ms : 1209600000
9090
91- cloud :
92- aws :
93- credentials :
94- access-key : ${AWS_ACCESS_KEY}
95- secret_key : ${AWS_SECRET_KEY}
96- region :
97- static : ${S3_REGION}
98- s3 :
99- bucket : ${S3_BUCKET_NAME}
100- cloudfront :
101- domain : ${CLOUD_FRONT_DOMAIN_NAME}
102-
10391management :
10492 endpoints :
10593 web :
@@ -135,4 +123,12 @@ otel:
135123 metrics :
136124 exporter : none
137125 logs :
138- exporter : none
126+ exporter : none
127+
128+ cloudflare :
129+ r2 :
130+ endpoint : ${CLOUDFLARE_R2_ENDPOINT}
131+ access-key : ${CLOUDFLARE_R2_ACCESS_KEY}
132+ secret-key : ${CLOUDFLARE_R2_SECRET_KEY}
133+ bucket : ${CLOUDFLARE_R2_BUCKET}
134+ public-url : ${CLOUDFLARE_R2_PUBLIC_URL}
Original file line number Diff line number Diff line change @@ -103,18 +103,6 @@ jwt:
103103 access-token-expiration-ms : 3600000
104104 refresh-token-expiration-ms : 1209600000
105105
106- cloud :
107- aws :
108- credentials :
109- access-key : ${AWS_ACCESS_KEY}
110- secret_key : ${AWS_SECRET_KEY}
111- region :
112- static : ${S3_REGION}
113- s3 :
114- bucket : ${S3_BUCKET_NAME}
115- cloudfront :
116- domain : ${CLOUD_FRONT_DOMAIN_NAME}
117-
118106oauth :
119107 success-redirect-url : http://localhost:5173
120108
@@ -138,4 +126,12 @@ otel:
138126 metrics :
139127 exporter : none
140128 logs :
141- exporter : none
129+ exporter : none
130+
131+ cloudflare :
132+ r2 :
133+ endpoint : ${CLOUDFLARE_R2_ENDPOINT}
134+ access-key : ${CLOUDFLARE_R2_ACCESS_KEY}
135+ secret-key : ${CLOUDFLARE_R2_SECRET_KEY}
136+ bucket : ${CLOUDFLARE_R2_BUCKET}
137+ public-url : ${CLOUDFLARE_R2_PUBLIC_URL}
Original file line number Diff line number Diff line change @@ -112,18 +112,6 @@ jwt:
112112 access-token-expiration-ms : 3600000
113113 refresh-token-expiration-ms : 1209600000
114114
115- cloud :
116- aws :
117- credentials :
118- access-key : ${AWS_ACCESS_KEY}
119- secret_key : ${AWS_SECRET_KEY}
120- region :
121- static : ${S3_REGION}
122- s3 :
123- bucket : ${S3_BUCKET_NAME}
124- cloudfront :
125- domain : ${CLOUD_FRONT_DOMAIN_NAME}
126-
127115management :
128116 endpoints :
129117 web :
@@ -173,3 +161,11 @@ otel:
173161 endpoint : ${OTEL_COLLECTOR_URL}
174162 compression : gzip
175163 timeout : 10s
164+
165+ cloudflare :
166+ r2 :
167+ endpoint : ${CLOUDFLARE_R2_ENDPOINT}
168+ access-key : ${CLOUDFLARE_R2_ACCESS_KEY}
169+ secret-key : ${CLOUDFLARE_R2_SECRET_KEY}
170+ bucket : ${CLOUDFLARE_R2_BUCKET}
171+ public-url : ${CLOUDFLARE_R2_PUBLIC_URL}
Original file line number Diff line number Diff line change 7272 access-token-expiration-ms : 3600000
7373 refresh-token-expiration-ms : 1209600000
7474
75- cloud :
76- aws :
77- credentials :
78- access-key : testAccessKey
79- secret_key : testSecretKey
80- region :
81- static : test-region
82- s3 :
83- bucket : test-bucket-name
84- cloudfront :
85- domain : testdomain.net
86-
8775de :
8876 flapdoodle :
8977 mongodb :
10088
10189verification :
10290 service :
103- url : http://localhost:5000/verify/url
91+ url : http://localhost:5000/verify/url
92+
93+ cloudflare :
94+ r2 :
95+ endpoint : http://test-endpoint
96+ access-key : test-access-key
97+ secret-key : test-secret-key
98+ bucket : test-bucket
99+ public-url : test-public-url
You can’t perform that action at this time.
0 commit comments