Spring Boot - Firebase cloud storage configuration and CRUD operations

Viewed 467

I am trying to find any simple and good examples of configuration and CRUD operations of Firebase cloud storage using Spring-boot but it seems there is not any good, simple and well-explained example for it. I would like someone help me find a good example or help me with some code of configuration and CRUD operations. Till now :

@PostConstruct
public void initialize() {

    try {
        FileInputStream serviceAccount =
                  new FileInputStream("./serviceAccount.json");

                FirebaseOptions options = new FirebaseOptions.Builder()
                  .setCredentials(GoogleCredentials.fromStream(serviceAccount))
                  .setDatabaseUrl("databaseUrl")
                  .setStorageBucket("bucket")
                  .build();


                FirebaseApp.initializeApp(options);
                Firestore db = FirestoreClient.getFirestore();

    } catch (Exception e) {
        e.printStackTrace();
    }
}

I was able to do CRUD operations in firebase database until added .setStorageBucket(bucket)

Error : Constructor threw exception; nested exception is java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist.
0 Answers
Related