Skip to content

Commit bd58037

Browse files
authored
Hotfix: 과릿 1.4.2 (#463)
1 parent 5cbe940 commit bd58037

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/main/java/com/selfrunner/gwalit/global/config/FCMConfig.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import javax.annotation.PostConstruct;
1414
import java.io.ByteArrayInputStream;
15+
import java.io.IOException;
1516
import java.io.InputStream;
1617
import java.nio.charset.StandardCharsets;
1718
import java.util.List;
@@ -21,7 +22,7 @@
2122
public class FCMConfig {
2223

2324
@Value("${firebase.config}")
24-
private String configFile;
25+
private ClassPathResource fcmServiceKey;
2526

2627
@Value("${firebase.scope}")
2728
private String scope;
@@ -38,12 +39,11 @@ public void initialize() {
3839
// // ByteArrayInputStream을 사용하여 바이트 배열을 InputStream으로 변환
3940
// InputStream inputStream = new ByteArrayInputStream(byteArray);
4041

41-
ClassPathResource resource = new ClassPathResource(configFile);
42-
InputStream inputStream = resource.getInputStream();
42+
System.out.println(fcmServiceKey);
4343

4444
// Service Account를 이용하여 Fireabse Admin SDK 초기화
4545
FirebaseOptions options = FirebaseOptions.builder()
46-
.setCredentials(GoogleCredentials.fromStream(inputStream).createScoped(List.of(scope)))
46+
.setCredentials(GoogleCredentials.fromStream(fcmServiceKey.getInputStream()).createScoped(List.of(scope)))
4747
.build();
4848

4949
if(FirebaseApp.getApps().isEmpty()) {
@@ -55,4 +55,10 @@ public void initialize() {
5555
throw new ApplicationException(ErrorCode.FAILED_FCM_INIT);
5656
}
5757
}
58+
59+
private String readResourceAsString(ClassPathResource resource) throws IOException {
60+
try (InputStream inputStream = resource.getInputStream()) {
61+
return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
62+
}
63+
}
5864
}

0 commit comments

Comments
 (0)