Home:ALL Converter>Get uid in firebase function onFinalize for firebase storage

Get uid in firebase function onFinalize for firebase storage

Ask Time:2019-11-13T06:08:25         Author:Wesley Overdijk

Json Formatter

I use the firebase JS sdk to upload audio files to firebase-storage. When this happens I need to process it based on the authenticated user doing the uploading (I upload it somewhere else for processing). This means I need to have access to the uid after it has been validated by storage rules, to keep it safe.

While researching this I found workarounds such as using the metadata to send the user's ID token but in my opinion this is a bad idea as it's possible to abuse.

I found this question which is pretty much exactly my question as well. The question I linked is now over a year old, so I thought it's worth asking again.

The primary reason I think that, is because of storage rules, which do have access to the uid (https://firebase.google.com/docs/storage/security/user-security). If I can use the uid there to allow/disallow access I assume it's also possible to access the uid in my onFinalize trigger. I just can't seem to find how.

Author:Wesley Overdijk,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/58827414/get-uid-in-firebase-function-onfinalize-for-firebase-storage
yy