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?
Asked
Active
Viewed 54 times
1 Answers
1
Cloud Functions are stateless, so there's no way to make a two-function setup like that.
Instead you'll want to:
- Pass the UID of the user as path of the path or filename, or add it to the metadata.
- Use security rules to ensure the user writes under their own UID as shown here.
- 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
-
Thanks that's a good idea to go with! It gave me a great insight on what to do! – peakystewie Nov 01 '20 at 09:01