firebasegoogle-cloud-firestorefirebase-storagefirebase-security

Billing for a Firebase Storage rule that access Firestore


I have a Firebase Storage rule that looks like this:

    match /mycoll/{pagenum}/picture.jpg {
        allow read: if true;
        allow write: if request.auth != null
           && firestore.get(/databases/(default)/documents/mycoll/$(pagenum)).data.owner == request.auth.uid; // CHECK OWNER
        allow delete: if false; // DISALLOW DELETE OPERATION
    }

as you notice only the write part makes a query to check for a match of the owner in Firestore.

My first question is:

My second question is:


Solution

  • will I get charged for a read in Firestore If I only try to download (read) the file picture.jpg from Firebase Storage?

    No. Your read rule doesn't do anything with Firestore, so will will incur no read costs.

    will I get charged in case of a failed write with reason = auth is null (first check before the && that reads in firestore)

    No. Security rules short-circuit booleans expressions and don't continue to evaluate sub-expressions when the entire expression is already known.

    See: