forked from emitapp/emit-server-public
-
Notifications
You must be signed in to change notification settings - Fork 0
/
storage.rules
55 lines (48 loc) · 1.77 KB
/
storage.rules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
//For Profile Pics
match /profilePictures {
// Cascade read to any image at the profilePictures path
// as long as there's an auth token
match /{allImages=**} {
allow read: if request.auth!=null
}
// Allow write files to the path "profilePictures/{uid}/*", subject to the constraints:
// 1) File is less than 10MB
// 2) Content type is an image
// 3) File name is less than 50 characters
// 4) The user's uid matches with the directory they're writing into
match /{userUid} {
match /{imageId} {
allow write: if request.resource.size < 10 * 1024 * 1024
&& request.resource.contentType.matches('image/.*')
&& imageId.size() < 50
&& request.auth.uid == userUid
}
}
}
//For group pics
match /groupPictures {
match /{allImages=**} {
allow read: if request.auth!=null
}
// Allow write files to the path "profilePictures/{groupUid}/*", subject to the constraints:
// 1) File is less than 10MB
// 2) Content type is an image
// 3) File name is less than 50 characters
// 4) They are logged in
//TODO: Make it so that only memebrs can chnage it!
//https://stackoverflow.com/questions/46861983/can-firebase-cloud-storage-rules-validate-against-firestore-data
//https://firebase.google.com/docs/storage/security/rules-conditions?hl=UK
match /{groupUid} {
match /{imageId} {
allow write: if request.resource.size < 10 * 1024 * 1024
&& request.resource.contentType.matches('image/.*')
&& imageId.size() < 50
&& request.auth!=null
}
}
}
}
}