1

I have created a Storage triggered cloud function, which is activated when the user uploads a file from the front end. Now I want to get the Firebase UID of the user that uploaded that file. I figured out that in order to do that, I need another function that is triggered when the user is authenticated. So, basically, the Authentication function is triggered when the user is logged in, then we get the UID and I want to pass this UID to the other function (Storage triggered one), and this is the part that I have been struggling with. Is there any way to do that?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
peakystewie
  • 141
  • 2
  • 17

1 Answers1

1

Cloud Functions are stateless, so there's no way to make a two-function setup like that.

Instead you'll want to:

  1. Pass the UID of the user as path of the path or filename, or add it to the metadata.
  2. Use security rules to ensure the user writes under their own UID as shown here.
  3. Then parse the UID from the path in your Cloud Functions code.

Also see these related questions:

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807