Firebase + gcloud存储+ nodejs。访问被拒绝错误

时间:2017-01-21 11:35:46

标签: node.js firebase google-cloud-storage firebase-storage gcloud

我正在尝试从urlfirebase-storage nodejs库获取我的图片gcloud

// Require gcloud
var gcloud = require('google-cloud');

// Enable Storage
var gcs = gcloud.storage({
    projectId: 'foo-project',
    keyFilename: 'path/to/key.json'
});

// Reference an existing bucket.
var bucket = gcs.bucket('foo-bucket.appspot.com');

var file = bucket.file('pictures/'+filename);

file.getSignedUrl({
    action: 'read',
    expires: '03-17-2025'
}, function(err, url) {
    log.error('GCLOUD', err) // null
    console.log(url) // im getting a url

});

请求回复了一个网址,但是当我访问它时,我收到此错误:

enter image description here

我从gcloud获得的网址与我从firebase获得的网址不同

来自gcloud = https://storage.googleapis.com/foo-bar.appspot.com/....

来自firebase = https://firebasestorage.googleapis.com/v0/b/mycure-v2.appspot.com/....

1 个答案:

答案 0 :(得分:0)

我相信问题是你的key.json。确保没事。