Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to handle two buckets in firebase storage when uploading files to firebase using angular

in app.module

AngularFireModule.initializeApp(environment.firebaseConfig)

I have two storage

firebaseConfig: {
    apiKey: 'AIzaSyBHsAxVgiuM0_xLd3BunTG6Yf9x1nynxoA',
    authDomain: 'careerograph-e9963.firebaseapp.com',
    databaseURL: 'https://careerograph-e9963.firebaseio.com',
    projectId: 'careerograph-e9963',
    storageBucket: 'careerograph-e9963.appspot.com',
    messagingSenderId: '669874223858'
  },
  firebaseExcelConfig: {
    apiKey: 'AIzaSyBHsAxVgiuM0_xLd3BunTG6Yf9x1nynxoA',
    authDomain: 'careerograph-e9963.firebaseapp.com',
    databaseURL: 'https://careerograph-e9963.firebaseio.com',
    projectId: 'careerograph-e9963',
    messagingSenderId: '669874223858',
    storageBucket: 'careerograph-excel',
  },

in component I inject in contructor private storage: AngularFireStorage then call

this.task = this.storage.upload(this.path, file, { customMetadata });

How can I choose a bucket to upload file to it

like image 289
Mohamed Abo Elmagd Avatar asked Oct 17 '22 20:10

Mohamed Abo Elmagd


1 Answers

In the documentation you can see:

// Get a non-default Storage bucket
var storage = firebase.app().storage('gs://my-custom-bucket');

The reference of the storage you have to define is in this way:

var storageRef = firebase.app().storage('my-custom-bucket').ref();
like image 58
Carlos Bayarri Cebrecos Avatar answered Oct 20 '22 22:10

Carlos Bayarri Cebrecos