如何在HTTP触发的firebase函数

时间:2017-12-21 12:07:54

标签: javascript firebase google-cloud-storage firebase-storage google-cloud-functions

我有HTTP触发的firebase功能,需要访问firebase存储,对其上的某个文件做一些工作,然后发回结果,但是 当我运行这段代码时,我得到了

    exports.test = functions.https.onRequest((request, response) => {
        const fileName = request.query.fileName; 
        const bucketName = request.query.bucketName; 
        const bucket = gcs.bucket(bucketName); 
        const tempFilePath = path.join(os.tmpdir(), fileName); 

        bucket.file(fileName).download({
            destination: tempFilePath
        }).then(() => {
            console.log("Downloaded file");

        }).catch(error => {
            console.log("failed downloading file");
            console.log(error);
        });
        response.send("tried downloading file"); 
    });

它到达带有错误的catch部分

ApiError: vactive-backend@appspot.gserviceaccount.com does not have storage.objects.get access to vactive-backend/my_script.py.

我检查过我把那个桶公之于众,我做错了什么?

0 个答案:

没有答案