【发布时间】:2020-05-17 11:11:12
【问题描述】:
我有一个非常简单的 Firebase 存储结构:
> check-in-station-content
> reports
这是两个文件夹,我正在尝试对 check-in-station-content 设置限制,以仅接受视频/mp4 文件,不大于 30MB 并且只能由以下人员上传认证的各方。所以,我的规则是这样的:
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read: if request.auth != null;
}
match /check-in-station-content {
// Allow write files, subject to the constraints:
// 1) File is less than 30MB
// 2) Content type is video/mp4
match /{videoId} {
allow write: if request.auth != null && request.resource.size < 30 * 1024 * 1024 && request.resource.contentType.matches('video/mp4')
}
}
}
}
然后,当我转到存储的 UI 并单击 上传 按钮时,没有什么能阻止我上传任何大小的文件
【问题讨论】:
标签: firebase firebase-storage firebase-security