I'm testing new Firebase Storage local Emulator. For my rules, it gives me the following error:
com.google.firebase.rules.runtime.common.EvaluationException: Error: {path/to/my/file/storage.rules} line [5], column [21]. Null value error.
The rules:
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /item/{id}/file.txt {
allow get: if request.auth.uid != null && request.auth.uid == resource.metadata.owner; // Error line 5
allow delete: if request.auth.uid != null && request.auth.uid == resource.metadata.owner;
// Only allow uploads of any image file that's less than 100MB
allow write: if request.auth.uid != null && request.auth.uid == request.resource.metadata.owner
&& request.resource.size < 100 * 1024 * 1024;
}
}
}
It seems like the rules for GET are invalid. Maybe it's because of the resource.metadata.owner that doesn't exist? If it's true, then how can I limit the access for owners of the file only?