存储功能的 Firebase 权限

Firebase permission for storage function

我正在尝试使用以下方法在存储桶中的特定路径上触发我的函数:

exports.generateThumbnail = functions.storage.bucket("users").object().onChange(event => {});

当我尝试部署它时,控制台显示:

functions[generateThumbnail]: Deploy Error: Insufficient permissions to (re)configure a trigger (permission denied for bucket users). Please, give owner permissions to the editor role of the bucket and try again.

我该怎么做?我需要设置 IAM 或存储桶权限还是其他?

看起来问题是您正在尝试引用名为 "users" 的存储桶,而不是在对象前缀上进行过滤。

你想要的是:

exports.generateThumbnail = functions.storage.object().onChange(event => {
  if (object.name.match(/users\//)) {
    // do whatever you want in the filtered expression!
  }
});

最终我们想让前缀过滤可用,这样您就可以做到 object("users"),但目前您必须像上面那样在您的函数中进行过滤。