Complete the code to allow read access only if the user is authenticated.
allow read: if request.auth [1] null;
The rule checks if the user is authenticated by verifying that request.auth is not null.
Complete the code to allow write access only if the user is the owner of the file.
allow write: if request.auth.uid == resource.metadata.ownerId && request.auth.uid [1] null;
The rule ensures the user is authenticated and is the owner by checking request.auth.uid is not null and matches resource.metadata.ownerId.
Fix the error in the rule that denies all access unintentionally.
allow read, write: if request.auth.uid [1] null;
The rule should allow access only if the user is authenticated, so it must check that request.auth.uid is not null using '!='.
Fill both blanks to allow uploads only if the file size is less than 5MB and the user is authenticated.
allow write: if request.resource.size [1] 5 * 1024 * 1024 && request.auth [2] null;
The rule checks that the file size is less than 5MB and that the user is authenticated by verifying request.auth is not null.
Fill all three blanks to allow read access only if the file is public or the user is the owner and authenticated.
allow read: if resource.metadata.isPublic == true || (request.auth.uid [1] null && request.auth.uid [2] resource.metadata.ownerId && resource.metadata.isPublic [3] false);
The rule allows read if the file is public or if the user is authenticated (not null), is the owner (uid equals ownerId), and the file is not public (false).