我尝试在Get Download URL from file uploaded with Cloud Functions for Firebase中按照答案进行操作。获取存储在Firebase存储器中的图像的下载URL
但是初始化下面的代码gcs
时我需要获取service-account.json keyFilename
const gcs = require('@google-cloud/storage')({keyFilename: 'service-account.json'})
我不知道如何正确设置{keyFilename: 'service-account.json'}
。但这是我所做的:
首先,我从此处生成私钥,并将其命名为service-account.json https://console.firebase.google.com/project/yourprojectID/settings/serviceaccounts/adminsdk,service-account.json包含以下信息:
{ “ type”:“ service_account”, “ project_id”:“”, “ private_key_id”:“”, “ private_key” :、 “ client_email”:“”, “ client_id”:“”, “ auth_uri”:“”, “ token_uri”:“”, “ auth_provider_x509_cert_url”:“”, “ client_x509_cert_url”:“” }
,然后将文件放在功能文件夹中,并使用它,如下图所示:
但是我从云功能日志中得到了错误:
{ Error: ENOENT: no such file or directory, open '../service-account.json'
at Error (native)
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '../service-account.json' }
当我使用以下代码将gcs
上传到存储设备时,var embedConfig = {
...
filters: [] //Empty array of filters.
};
var $reportContainer = $('#reportContainer');
var report = powerbi.embed($reportContainer.get(0), embedConfiguration);
实际上用于生成缩略图:{>
答案 0 :(得分:0)
新手错误,应该是./service-account.json
而不是../service-account.json