forked from googlearchive/friendlypix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstorage.rules
21 lines (20 loc) · 847 Bytes
/
storage.rules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Returns true if the given UID matches the signed in UID,
// the uploaded file is an image and its size is below the given number of MB.
// Also allow deletes.
function isImageAndBelowMaxSize(uid, maxSizeMB) {
return request.auth.uid == uid
&& (request.resource == null // Allow deletes
|| request.resource.size < maxSizeMB * 1024 * 1024 // Max size for the uploaded file
&& request.resource.contentType.matches('image/.*')) // The file is an image
}
service firebase.storage {
// TODO: Change the <STORAGE_BUCKET> placeholder below
match /b/<STORAGE_BUCKET>/o {
match /{userId}/thumb/{timeStamp}/{fileName} {
allow read, write: if isImageAndBelowMaxSize(userId, 1);
}
match /{userId}/full/{timeStamp}/{fileName} {
allow read, write: if isImageAndBelowMaxSize(userId, 5);
}
}
}