防止从 Firebase 存储中删除文件
Prevent file deletion from firebase storage
我阅读了有关安全和规则的整个存储文档,但没有发现任何阻止用户删除 firebase 存储中现有文件的示例。
我尝试使用 crc32 和如下资源,但它似乎无法正常工作:
allow write: if request.resource.crc32c == resource.crc32c; // doesn't work (cannot create a new resource)
allow write: if request.resource; // doesn't work (cannot create a new resource) either
它无法实现会让我感到惊讶。
通过检查资源大小解决了问题:
allow write: if request.resource.size > 0
更好的方法是
allow write: if request.auth != null && request.method != 'delete' && request.method!= 'update';
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read: if false
allow write: if request.method != 'delete' && request.method!= 'update';
}
}
}
我阅读了有关安全和规则的整个存储文档,但没有发现任何阻止用户删除 firebase 存储中现有文件的示例。
我尝试使用 crc32 和如下资源,但它似乎无法正常工作:
allow write: if request.resource.crc32c == resource.crc32c; // doesn't work (cannot create a new resource)
allow write: if request.resource; // doesn't work (cannot create a new resource) either
它无法实现会让我感到惊讶。
通过检查资源大小解决了问题:
allow write: if request.resource.size > 0
更好的方法是
allow write: if request.auth != null && request.method != 'delete' && request.method!= 'update';
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read: if false
allow write: if request.method != 'delete' && request.method!= 'update';
}
}
}