5

在 app.module 中

AngularFireModule.initializeApp(environment.firebaseConfig)

我有两个存储

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',
  },

在我注入构造函数私有存储的组件中:AngularFireStorage 然后调用

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

我如何选择一个桶来上传文件到它

4

1 回答 1

3

在文档中您可以看到:

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

您必须定义的存储的引用是这样的:

var storageRef = firebase.app().storage('my-custom-bucket').ref();
于 2020-10-05T06:34:03.513 回答