-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstorage.rules
More file actions
27 lines (22 loc) · 766 Bytes
/
Copy pathstorage.rules
File metadata and controls
27 lines (22 loc) · 766 Bytes
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
rules_version = '2';
// Returns true if the uploaded file is an image and its size is below the given number of MB.
function isImageBelowMaxSize(maxSizeMB) {
return request.resource.size < maxSizeMB * 1024 * 1024
&& request.resource.contentType.matches('image/.*');
}
function isSignedIn() {
return request.auth != null
&& request.auth.token.firebase.sign_in_provider != 'anonymous'
}
service firebase.storage {
match /b/{bucket}/o {
match /users/{userId}/{fileName} {
allow write, update: if isSignedIn() && request.auth.uid == userId && isImageBelowMaxSize(5);
allow read;
}
match /posts/{postId}/{fileName} {
allow write: if isSignedIn() && isImageBelowMaxSize(5);
allow read;
}
}
}