【发布时间】:2018-05-02 08:16:38
【问题描述】:
这在本地服务中与 firebase 完美配合:
const gCloudConfig = {
projectId: 'XXXX-X1234',
keyFilename: './key.json'
}
const Storage = require('@google-cloud/storage')(gCloudConfig);
const storageBucket = Storage.bucket(bucketUrl);
storageBucket.upload(file.path, {destination: file.name})
.then(() => {
//
});
但是当我部署到 firebase 时这不起作用:
const Storage = require('@google-cloud/storage')();
const storageBucket = Storage.bucket(bucketUrl);
storageBucket.upload(file.path, {destination: file.name})
.then(() => {
//
});
我将这一行放在admin.initializeApp(...) 之后,因为我看到它为某人解决了问题,但它仍然不起作用。
我尝试了很多东西:
const gCloudConfig = { projectId: 'XXXX-X1234' };
const gCloudConfig = { key: API_KEY };
const gCloudConfig = { key: API_KEY, projectId: 'XXXX-X1234' };
const gCloudConfig = functions.config().firebase;
我有点迷路了,请帮帮我!
【问题讨论】:
标签: firebase google-cloud-storage google-cloud-functions