【发布时间】:2019-02-25 18:30:10
【问题描述】:
您好,我对文件夹 /posts/media/{userId}/{media} 有如下规则:
service firebase.storage {
match /b/{bucket}/o {
match /{allPath=**} {
allow read, create, write;
}
match /posts/media {
allow create: if request.auth != null && request.resource.size < 10 * 1024 * 1024
&& request.resource.contentType.matches('(image|video)/.*');
match /{userId}/{allPaths=**} {
allow create, write: if request.auth.uid == userId && request.resource.size < 10 * 1024 * 1024
&& request.resource.contentType.matches('(image|video)/.*');
}
}
}
}
不强制要求 10MB 的文件大小。用户可以轻松发布数倍于 10MB 限制的视频。
有什么帮助吗?
谢谢你, 米歇尔
【问题讨论】:
-
如果不查看执行上传的代码,就无法查看您的规则和代码是否真正符合您的预期。我们需要能够看到您的代码实际上将文件上传到受安全规则保护的位置。我建议首先从一些非常简单的规则开始,以确保它们按预期触发,然后让它们变得更复杂。
-
确实如此,因为文件最终到达了预期的位置。除了它接受大于限制的文件。上传有效,但它不应该接受这么大的文件。
标签: firebase firebase-storage firebase-security