From 044785f125d967ab04177848d0981b4358dac791 Mon Sep 17 00:00:00 2001 From: Gouyeon Chung Date: Wed, 30 Oct 2024 15:51:09 +0900 Subject: [PATCH] =?UTF-8?q?FIX=20:=20/tmp=20=EC=97=90=20fcm=20key=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../short_news/core/config/FCMConfig.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/kkokkomu/short_news/core/config/FCMConfig.java b/src/main/java/com/kkokkomu/short_news/core/config/FCMConfig.java index db27d7d..06a2db1 100644 --- a/src/main/java/com/kkokkomu/short_news/core/config/FCMConfig.java +++ b/src/main/java/com/kkokkomu/short_news/core/config/FCMConfig.java @@ -8,6 +8,8 @@ import org.springframework.context.annotation.Configuration; import org.springframework.core.io.ClassPathResource; +import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.List; @@ -15,17 +17,20 @@ @Configuration public class FCMConfig { - @Bean public FirebaseMessaging firebaseMessaging() throws IOException { - // 1. firebase_key.json을 ClassPath에서 로드 - ClassPathResource resource = new ClassPathResource("firebase/firebase_service_key.json"); + // 1. /tmp 경로에서 firebase_service_key.json 파일 로드 + File firebaseKeyFile = new File("/tmp/firebase_service_key.json"); - try (InputStream refreshToken = resource.getInputStream()) { + if (!firebaseKeyFile.exists()) { + throw new IllegalStateException("Firebase key file not found at /tmp/firebase_service_key.json"); + } + + try (FileInputStream refreshToken = new FileInputStream(firebaseKeyFile)) { // 2. Firebase 앱 인스턴스가 이미 있는지 확인 List firebaseApps = FirebaseApp.getApps(); FirebaseApp firebaseApp; - if (firebaseApps != null && !firebaseApps.isEmpty()) { + if (!firebaseApps.isEmpty()) { // 기존 인스턴스가 있으면 재사용 firebaseApp = FirebaseApp.getInstance(); } else {