The Firebase documentation on security rules has an example that shows (amongst others) how to set the maximum size of files that can be stored:
service firebase.storage {
match /b/{bucket}/o {
match /images {
// Cascade read to any image type at any path
match /{allImages=**} {
allow read;
}
// Allow write files to the path "images/*", subject to the constraints:
// 1) File is less than 5MB
// 2) Content type is an image
// 3) Uploaded content type matches existing content type
// 4) File name (stored in imageId wildcard variable) is less than 32 characters
match /{imageId} {
allow write: if request.resource.size < 5 * 1024 * 1024
&& request.resource.contentType.matches('image/.*')
&& request.resource.contentType == resource.contentType
&& imageId.size() < 32
}
}
}
}
Since these rules will only be applied after the actual upload has completed (but before the file is actually stored in your storage bucket), you'll typically also want to check the file size in your Android app before uploading it, to prevent using bandwidth for a file that is too large. For some examples of how to check the local file size on Android, see Get the file size in android sdk?