service firebase.storage {
match /b/<your-bucket>/o {
match /path/to/file {
// !resource allows the upload of a new file
// hash comparison allows re-upload of the same file
// note that property names are case-sensitive
allow write: if !resource || request.resource.md5Hash == resource.md5Hash;
}
}
}
2条答案
按热度按时间wswtfjt71#
我认为你想要这些的组合:
dtcbnfnu2#
使用
resource == null
代替。这确实是从文档中缺失的,但在md5注解下的mentioned:
注意:MD5哈希冲突是可能的,并且可能允许某人覆盖文件,即使存在上述规则。考虑额外的文件验证或其他规则来强制不变性(例如,
allow write: if resource == null;
)