Created
March 10, 2017 21:00
-
-
Save stevekinney/d7dbd2e756f4a3780229b75cd7c5a232 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"rules": { | |
".read": "auth != null", | |
"users": { | |
"$userId": { | |
".write": "$userId === auth.uid" | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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