I need to check a document's data in Firestore to allow someone to view an image in Firebase Storage. Is this possible?
Asked
Active
Viewed 578 times
1 Answers
4
Edit: it is now possible to query Firestore from Storage security rules. You can read about it here and read the documentation here.
Original answer:
It is currently not possible to access Cloud Firestore documents directly from Cloud Storage rules. You have two options:
- Somehow use Firebase Authentication custom claims on the user account to determine if a user should be able to access a file.
- 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.

Doug Stevenson
- 297,357
- 32
- 422
- 441
-
1Thanks. Hope they make this a feature soon! – Ken Mueller Jul 04 '19 at 01:06
-
This is no longer true. See https://firebase.blog/posts/2022/09/announcing-cross-service-security-rules and my updated answer here https://stackoverflow.com/a/49054022/209103 – Frank van Puffelen Oct 26 '22 at 19:01