我收到“用户无权访问此对象”。当我尝试授予每个用户对Firebase中其用户名根目录下的所有文件的权限时,如下所示:
service firebase.storage {
match /b/bucketname.appspot.com/o {
match /users/{userId}/* {
allow read;
allow write: if request.auth.uid == userId;
}
}
}
但我收到com.google.firebase.storage.StorageException:用户无权访问此对象。
如何以不同方式设置权限?
以下是https://firebase.google.com/docs/storage/security/user-security
的官方示例// Only a user can upload their profile picture, but anyone can view it
match /users/{userId}/profilePicture.png {
allow read;
allow write: if request.auth.uid == userId;
}
但是,我不想让用户访问特定文件,而是希望授予经过身份验证的用户权限,以便在用户ID之后写入路径
答案 0 :(得分:2)
尝试这种方式:
service firebase.storage {
match /b/xxxx.appspot.com/o {
match /{allPaths=**} {
allow read;
allow write: if request.auth != null;
}
}
}