-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstorage.rules
More file actions
42 lines (36 loc) · 1.02 KB
/
storage.rules
File metadata and controls
42 lines (36 loc) · 1.02 KB
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
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
// Helper functions
function isSignedIn() {
return request.auth != null;
}
function isOwner(userId) {
return request.auth.uid == userId;
}
function isImageFile() {
return request.resource.contentType.matches('image/.*');
}
function isValidFileSize() {
return request.resource.size <= 5 * 1024 * 1024; // 5MB max
}
// Profile images
match /profileImages/{userId} {
allow read: if isSignedIn();
allow write: if isSignedIn() &&
isOwner(userId) &&
isImageFile() &&
isValidFileSize();
}
// Task attachments
match /tasks/{taskId}/{fileName} {
allow read: if isSignedIn();
allow write: if isSignedIn() && isValidFileSize();
}
// Resource files
match /resources/{resourceId}/{fileName} {
allow read: if isSignedIn();
allow write: if isSignedIn() && isValidFileSize();
}
}
}