5

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

Mohamed Abo Elmagd
  • 1,077
  • 11
  • 17
  • Before asking a question, please be sure the [read the documentation](https://firebase.google.com/docs/storage/web/start#use_multiple_storage_buckets). –  Mar 26 '18 at 06:38
  • I'm voting to close this question as off-topic because the answer is provided in the official documentation of the library. –  Mar 26 '18 at 06:38
  • I want to use upload method and it is not available to firebase – Mohamed Abo Elmagd Mar 26 '18 at 07:41
  • Did you get a solution to this? In answer to the comment above the question is about angularfire storage and the docs are for pure firebase. – MadMac Aug 24 '20 at 22:44
  • @MadMac , No I didn't get a solution – Mohamed Abo Elmagd Aug 26 '20 at 12:13

1 Answers1

3

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();