我目前有此项目(以一个为例,但还有更多)
Luke-Muñiz.jpg
我在gs://example.com/images/
中看到了然后我像这样打电话给firebase:
props.firebase.storageRef(`images/${props.data.profilePic}`).getDownloadURL().then(url => {
setImgRef(url);
[执行上述操作时出现403错误。
FirebaseStorageError {code_: "storage/object-not-found", message_: "Firebase Storage: Object 'images/Luke-Muñiz.jpg' does not exist.", serverResponse_: "{↵ "error": {↵ "code": 404,↵ "message": "No…not get object",↵ "status": "GET_OBJECT"↵ }↵}", name_: "FirebaseError"}
然后当然是GET网址给出了404
https://firebasestorage.googleapis.com/v0/b/example-bda7b.appspot.com/o/images%2FLuke-Mu%C3%B1iz.jpg
我的存储规则是:
1
rules_version = '2';
2
service firebase.storage {
3
match /b/{bucket}/o {
4
match /{allPaths=**} {
5
allow read, write: if request.auth != null;
6
}
7
}
8
}
9
我可以确认自己已登录,因为我可以查看某些图像。知道我在做什么错吗?
也许ñ令人困惑(请参阅摘要)。尝试encodeURI
您的props.data.profilePic
。
const name = 'Muñiz'; // copied from question
const encoded = encodeURI(name);
console.log(encoded);
const decoded = decodeURI(encoded);
console.log(decoded);
const yours = decodeURI('Mu%C3%B1iz'); // copied from question
console.log(yours);