I am trying to impose a limit on file upload size using the code below (request.resource.size < 5 * 1024 * 1024) and when uploading an image I get a permission denied error.
After running it in the simulator, I concluded that the requirement causing errors was the size below 5MB check. In the simulator an error is thrown (Property size is undefined on object.) and when I inspected the request.resource object, there was no size property, only contentType, name and bucket.
How can I correctly impose this 5MB limit?
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /profile_images/{profileImgId}/{imgId} {
allow create, update: if request.auth.uid == profileImgId
&& request.resource.size < 5 * 1024 * 1024
&& request.resource.contentType.matches('(?i)image/(jpeg|jpg|png)');
allow delete: if false;
allow get: if request.auth.uid == profileImgId;
}
}
}

