-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstorage.rules
More file actions
31 lines (25 loc) · 742 Bytes
/
storage.rules
File metadata and controls
31 lines (25 loc) · 742 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
28
29
30
31
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /samples {
// every can read everything
match /{allSamples=**} {
allow read;
}
// only admin can upload to public
match /public/{sample} {
allow write: if isAdmin(request) && isAudioFile(request);
}
// users can upload in their own folder
match /user/{userId}/{sample} {
allow write: if request.auth.uid == userId && isAudioFile(request);
}
}
}
}
function isAudioFile(request) {
return request.resource.contentType.matches('audio/.*');
}
function isAdmin(request) {
return request.auth != null && request.auth.token.admin == true;
}