Skip to content

Commit 7b6b9c7

Browse files
authored
update: [File] 파일 환경변수 오류 수정 (#74)
1 parent a6aa8ae commit 7b6b9c7

4 files changed

Lines changed: 10 additions & 6 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ jobs:
5050
Firebase_ID: ${{ secrets.FIREBASE_PROJECT_ID }}
5151
GOOGLE_MAP_API_KEY: ${{ secrets.GOOGLE_MAP_API_KEY }}
5252
SPRING_DOMAIN: ${{ secrets.SPRING_DOMAIN }}
53+
FILE_UPLOAD_DIR: ./uploads
5354
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
5455
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }}
5556
S3_REGION: ${{ secrets.S3_REGION }}

.github/workflows/deploy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ jobs:
4747
echo "S3_REGION=${{ secrets.S3_REGION }}" >> .env
4848
echo "S3_BUCKET=${{ secrets.S3_BUCKET }}" >> .env
4949
echo "S3_BASE_URL=${{ secrets.S3_BASE_URL }}" >> .env
50+
echo "FILE_UPLOAD_DIR=/app/uploads" >> .env
5051
5152
mkdir -p ./src/main/resources/firebase
5253
echo '${{ secrets.FCM_JSON }}' > ./src/main/resources/${{ secrets.FIREBASE_SERVICE_ACCOUNT_KEY }}

runtracker/src/main/java/com/runtracker/global/config/FileUploadConfig.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,17 @@
1111
@Configuration
1212
public class FileUploadConfig {
1313

14-
@Value("${file.upload-dir:/app/uploads}")
14+
@Value("${file.upload-dir}")
1515
private String uploadDir;
1616

17-
@Value("${app.domain:http://localhost:8080}")
17+
@Value("${file.base-url}")
1818
private String baseUrl;
1919

2020
@PostConstruct
2121
public void init() {
2222
File uploadDirectory = new File(uploadDir);
23-
if (!uploadDirectory.exists()) {
24-
if (!uploadDirectory.mkdirs()) {
25-
System.out.println("Warning: Failed to create upload directory: " + uploadDir);
26-
}
23+
if (!uploadDirectory.exists() && !uploadDirectory.mkdirs()) {
24+
throw new IllegalStateException("Failed to create upload directory: " + uploadDir);
2725
}
2826
}
2927
}

runtracker/src/main/resources/application.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ google:
7676
maps:
7777
api-key: ${GOOGLE_MAP_API_KEY}
7878

79+
file:
80+
upload-dir: ${FILE_UPLOAD_DIR}
81+
base-url: ${SPRING_DOMAIN}
82+
7983
aws:
8084
access-key: ${S3_ACCESS_KEY}
8185
secret-key: ${S3_SECRET_KEY}

0 commit comments

Comments
 (0)