部署 Firebase 功能时权限不足的问题

时间:2021-06-24 16:36:17

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

我使用命令 firebase deploy --only "functions:onWikiWrite" 部署了一个 firebase 函数。

我收到此错误:Error: Functions did not deploy properly.。 firebase 函数日志说

<块引用>

"status":{"code":7,"message":"没有足够的权限来(重新)配置触发器(存储桶 myBucket 的权限被拒绝)。请为存储桶的编辑者角色授予所有者权限并尝试再次。

打字稿代码?

import * as functions from "firebase-functions";
import * as admin from "firebase-admin";

import serviceAccount from "/Users/300041370/Downloads/serviceKey.json";

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
});

const buckObj = functions.storage.bucket("myBucket").object();
export const onWikiWrite = buckObj.onFinalize(async (object) => {
  const filePath = object.name ?? "test.json";
  const bucket = admin.storage().bucket("myBucket");

  bucket.file(filePath).download().then((data) => {
    const contents = data[0];
  data = {"key": "value"};
const doc = admin.firestore().collection("myCollection").doc();
doc.set(data);
  });
});

此功能的服务帐号的服务帐号角色? Service Account Roles

0 个答案:

没有答案