Skip to content

Instantly share code, notes, and snippets.

@stevekinney
Created March 10, 2017 21:00
Show Gist options
  • Save stevekinney/d7dbd2e756f4a3780229b75cd7c5a232 to your computer and use it in GitHub Desktop.
Save stevekinney/d7dbd2e756f4a3780229b75cd7c5a232 to your computer and use it in GitHub Desktop.
{
"rules": {
".read": "auth != null",
"users": {
"$userId": {
".write": "$userId === auth.uid"
}
}
}
}
function isCorrectUser(userId) {
return request.auth.uid == userId;
}
function isLessThanNMegabytes(n) {
return request.resource.size < n * 1024 * 1024;
}
service firebase.storage {
match /b/{bucket}/o {
allow read;
match /user-images/{userId}/{allPaths=**} {
allow write: if isCorrectUser(userId) &&
isLessThanNMegabytes(5);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment