-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstorage.rules
More file actions
97 lines (81 loc) · 2.52 KB
/
storage.rules
File metadata and controls
97 lines (81 loc) · 2.52 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
// Helper functions
function isAuthenticated() {
return request.auth != null;
}
function isOwner(userId) {
return isAuthenticated() && request.auth.uid == userId;
}
function isValidImageSize() {
return request.resource.size < 20 * 1024 * 1024; // 20MB
}
function isValidFileSize() {
return request.resource.size < 20 * 1024 * 1024; // 20MB
}
function isImage() {
return request.resource.contentType.matches('image/.*');
}
function isPDF() {
return request.resource.contentType == 'application/pdf';
}
function isVideo() {
return request.resource.contentType.matches('video/.*');
}
function isAudio() {
return request.resource.contentType.matches('audio/.*');
}
// User profile images
match /users/{userId}/profile/{fileName} {
allow read: if true; // Public read
allow write: if isOwner(userId)
&& isValidImageSize()
&& isImage();
}
// User uploaded files (PDFs for analysis)
match /users/{userId}/uploads/{fileName} {
allow read: if isOwner(userId);
allow write: if isOwner(userId)
&& isValidFileSize()
&& (isImage() || isPDF());
allow delete: if isOwner(userId);
}
// SOHAM: User uploaded images (camera/file picker)
match /user-image/{userId}/{fileName} {
allow read: if isOwner(userId);
allow write: if isOwner(userId)
&& isValidImageSize()
&& isImage();
allow delete: if isOwner(userId);
}
// SOHAM: Generated images (from AI)
match /generated-image/{userId}/{fileName} {
allow read: if isOwner(userId);
allow write: if isOwner(userId)
&& isValidImageSize()
&& isImage();
allow delete: if isOwner(userId);
}
// SOHAM: Generated videos (from AI)
match /generated-video/{userId}/{fileName} {
allow read: if isOwner(userId);
allow write: if isOwner(userId)
&& isValidFileSize()
&& isVideo();
allow delete: if isOwner(userId);
}
// SOHAM: Audio files (recordings, TTS)
match /audio/{userId}/{fileName} {
allow read: if isOwner(userId);
allow write: if isOwner(userId)
&& isValidFileSize()
&& isAudio();
allow delete: if isOwner(userId);
}
// Deny all other access
match /{allPaths=**} {
allow read, write: if false;
}
}
}