【发布时间】:2020-07-23 07:26:55
【问题描述】:
FileInputStream serviceAccount =
new FileInputStream("push-manager-app/src/main/resources/serviceAccountKey.json");
FirebaseOptions options = new FirebaseOptions.Builder()
.setCredentials(GoogleCredentials.fromStream(serviceAccount))
.setDatabaseUrl("https://test1-use.firebaseio.com")
.build();
FirebaseApp.initializeApp(options);
Firebase 连接器的上述代码工作正常。但是在openshift 环境中,我不能在资源中提交serviceAccountKey.json,因为不同的环境会有所不同。我可以在每个环境中从openshift configmap 中将其作为String 获取。
为了运行这段代码,我需要将String 转换为FileInputStream。我不知道该怎么做。我有一种解决方法,我可以读取String,生成文件并使用它。但我想使用正确的方法。我检查了Firebase API 的其他选项,但它甚至无法处理InputStream。
【问题讨论】:
标签: java spring-boot push-notification firebase-cloud-messaging openshift