firebase 中允许任何用户保存图像并且任何经过身份验证的用户读取其他用户头像的正确规则是什么?
What is the correct rule in firebase that allows any user to save an image and any authenticated user read others users avatars?
我正在使用 react-native 和 react-native-fetch-blob 及其 pollyfills 将图像上传到 firebase 存储。我无法按照文档进行操作,经过多次尝试后,我决定询问如何设置正确的 firebase 存储规则以避免出现此消息:
Firebase Storage: User does not have permission to access 'avatars/dTRYaMBELiNySUoml7h7JrNyZsg2
dTRYaMBELiNySUoml7h7JrNyZsg2 是 uid
,因为我将树组织为 gs://_______.appspot。com/avatars 是根我所有用户的头像,所以我可以使用任何用户 UID 检索它的头像。
允许用户上传其图像并允许任何经过身份验证的用户阅读这些头像的正确 firebase 存储规则是什么?
类似于:
service firebase.storage {
match /b/{bucket}/o {
match /avatars/{userId} {
allow read: if request.auth != null;
allow write: if request.auth.uid == userId;
}
}
}
每个:https://firebase.google.com/docs/storage/security/user-security
我正在使用 react-native 和 react-native-fetch-blob 及其 pollyfills 将图像上传到 firebase 存储。我无法按照文档进行操作,经过多次尝试后,我决定询问如何设置正确的 firebase 存储规则以避免出现此消息:
Firebase Storage: User does not have permission to access 'avatars/dTRYaMBELiNySUoml7h7JrNyZsg2
dTRYaMBELiNySUoml7h7JrNyZsg2 是 uid
,因为我将树组织为 gs://_______.appspot。com/avatars 是根我所有用户的头像,所以我可以使用任何用户 UID 检索它的头像。
允许用户上传其图像并允许任何经过身份验证的用户阅读这些头像的正确 firebase 存储规则是什么?
类似于:
service firebase.storage {
match /b/{bucket}/o {
match /avatars/{userId} {
allow read: if request.auth != null;
allow write: if request.auth.uid == userId;
}
}
}
每个:https://firebase.google.com/docs/storage/security/user-security