Firebase存储通配符规则
我目前正在使用NodeJS、HTML和Firebase编写一个网站,用于数据库服务、身份验证和存储。我目前遇到的问题是,根据我对文档的解释,Firebase存储规则不起作用 我的Firebase存储实例的目录结构如下(带有明显的假uid): 我想使存储在不同用户文件中的文件无论是否经过身份验证都能被任何用户读取,然后使私人文件夹中的文件仅对登录用户可用。我当前的Firebase存储规则如下所示:Firebase存储通配符规则,firebase,firebase-storage,firebase-security,Firebase,Firebase Storage,Firebase Security,我目前正在使用NodeJS、HTML和Firebase编写一个网站,用于数据库服务、身份验证和存储。我目前遇到的问题是,根据我对文档的解释,Firebase存储规则不起作用 我的Firebase存储实例的目录结构如下(带有明显的假uid): 我想使存储在不同用户文件中的文件无论是否经过身份验证都能被任何用户读取,然后使私人文件夹中的文件仅对登录用户可用。我当前的Firebase存储规则如下所示: service firebase.storage { match /b/{bucket}/o
service firebase.storage {
match /b/{bucket}/o {
match /users/{userId} {
match /* {
allow read;
}
match /private {
allow read, write: if request.auth != null;
}
}
}
}
根据这些规则,无论文件是否在私有目录中,如果不使用Firebase Storage提供的自定义下载令牌,我总是会在任何文件上得到403:“权限被拒绝。无法执行此操作”。我还尝试了以下规则,也得到了每个文件403的结果
service firebase.storage {
match /b/{bucket}/o {
match /users/{userId}/* {
allow read;
}
match /users/{userId}/private {
allow read, write: if request.auth != null;
}
}
}
为什么这些规则集不能正常工作?您应该使用它来匹配/users/{userId}/*
service firebase.storage {
match /b/{bucket}/o {
match /users/{userId} {
match /{imageId}{
allow read;
}
match /private/{imageId}{
allow read, write: if request.auth != null;
}
}
}
}
service firebase.storage {
match /b/{bucket}/o {
match /users/{userId} {
match /{imageId}{
allow read;
}
match /private/{imageId}{
allow read, write: if request.auth != null;
}
}
}
}