Vishwajeet Vatharkar
Vishwajeet Vatharkar

Reputation: 1196

How to use Firebase Storage to upload to existing Google cloud storage bucket?

From this documentation, https://firebase.google.com/docs/storage/web/upload-files we can upload files to a bucket that is created and managed by Firebase (using the default App engine project managed by Firebase)

But how to use Firebase to use an existing storage bucket, that is NOT managed by Firebase (though it has admin access to the same Google cloud account as that used to create the Firebase app)?

Upvotes: 2

Views: 1156

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317497

Initialize a dedicated instance of App using firebase.initializeApp(). You should be able to tell it the storage bucket you want to use when dealing with that app. Note that this is going to be separate from your default Firebase app, and you have to call it out every time you want to use it.

From the API docs linked above:

// Initialize another app
var otherApp = firebase.initializeApp({
  databaseURL: "https://<OTHER_DATABASE_NAME>.firebaseio.com",
  storageBucket: "<OTHER_STORAGE_BUCKET>.appspot.com"
}, "otherApp");

Then you should be able to access the storage for otherApp as suggested in firebase.storage():

firebase.storage(otherApp)

Upvotes: 3

Related Questions