kris
kris

Reputation: 55

Firebase permission for storage function

I'm trying to trigger my function on specific path in storage bucket using:

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

When I try to deploy it, console shows:

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.

How can I do that? Do I nedd to setup IAM or bucket permission or maybe something else?

Upvotes: 2

Views: 1115

Answers (1)

Mike McDonald
Mike McDonald

Reputation: 15963

Looks like the issue is that you're trying to reference a bucket named "users" rather than filtering on an object prefix.

What you want is:

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

Eventually we want to make prefix filtering available so you can do object("users"), but currently you have to filter in your function like above.

Upvotes: 3

Related Questions