Ad

Firebase Storage Rules That Query Data From Firestore

I need to check a document's data in Firestore to allow someone to view an image in Firebase Storage. Is this possible?

Ad

Answer

It is currently not possible to access Cloud Firestore documents directly from Cloud Storage rules. You have two options:

  1. Somehow use Firebase Authentication custom claims on the user account to determine if a user should be able to access a file.
  2. Use some backend code (maybe a Cloud Functions HTTP trigger) that the user accesses to download the file if the conditions are met.

In either case, you will need some backend code that checks and sets the appropriate data.

Ad
source: stackoverflow.com
Ad