0

How to get uid of the authenticated user from the storage trigger below:

exports.storageSizeCounter = functions.storage.object().onFinalize(async (object, context) => {...});

auth/uid is available during security rule evaluation but it seems like it's not passed to the trigger (like in context.auth).

Any way to get the uid inside the storage trigger?

vir us
  • 9,920
  • 6
  • 57
  • 66
  • That trigger doesn't have context available, you don't have access to the user uid on that function https://firebase.google.com/docs/storage/extend-with-functions – andresmijares Jul 13 '20 at 13:11
  • As andresmijares commented, the user information is not available by default. If you need it, the common approach is to pass the UID as part of the path or in the metadata, and then use security rules to ensure it is correct. See https://stackoverflow.com/q/60460257, https://stackoverflow.com/a/58827666 – Frank van Puffelen Jul 13 '20 at 15:09

0 Answers0