Firebase存储映像上载:400错误请求。无法访问存储桶
我设置了一个firebase web项目,无法使存储上传工作。我按照指示去做 我的存储桶权限是公共的(如果我将Firebase存储映像上载:400错误请求。无法访问存储桶,firebase,firebase-storage,http-status-code-400,Firebase,Firebase Storage,Http Status Code 400,我设置了一个firebase web项目,无法使存储上传工作。我按照指示去做 我的存储桶权限是公共的(如果我将{bucket}更改为实际名称,则没有区别) 我的代码是 export function upload (fileName, file) { let ref = firebase.storage().ref() ref.child(fileName).putString(file, 'data_url').then(snapshot => { console.lo
{bucket}
更改为实际名称,则没有区别)
我的代码是
export function upload (fileName, file) {
let ref = firebase.storage().ref()
ref.child(fileName).putString(file, 'data_url').then(snapshot => {
console.log('Uploaded file')
}).catch(e => console.error(e))
错误是
{
"error": {
"code": 400,
"message": "Bad Request. Could not access bucket xx-xxx.appspot.com"
}
}
我尝试过使用bucket权限,并尝试在google云存储中添加权限,但没有任何帮助。任何想法都将不胜感激 不要对bucket使用通配符,而是将其写入规则中,如下所示:
service firebase.storage {
match /b/xx-xxx.appspot.com/o {
match /{allPaths=**} {
allow read, write;
}
}
}
编辑:
仅对于公开阅读,请尝试:
service firebase.storage {
match /b/xx-xxx.appspot.com/o {
match /{allPaths=**} {
allow read;
allow write: if request.auth != null;
}
}
}
service firebase.storage {
match /b/xx-xxx.appspot.com/o {
match /{allPaths=**} {
allow read;
allow write: if request.auth != null;
}
}
}