英文:
Logs return object not found in firebase storage but it exist in the firebase storage console?
问题
我收到了以下错误:
FirebaseError: Firebase Storage:对象 'Bakery/Bakery Cuisine' 不存在(storage/object-not-found)
但是我最后检查的时候:
[![输入图片说明][1]][1]
路径是存在的,而且我大约30分钟前刚上传了一个文件。那么为什么 Firebase 存储说它不存在呢?
我想要做的是:能够下载 ```paramKey``` 路径下所有 .txt 文件中的内容,然后将该内容显示给用户看。
代码:
const [toReadfb, setToReadDatafb] = useState([])
useEffect (() => {
const rfb = sRef(storage, paramKey)
const output = getDownloadURL(rfb)
.then(function (url) {
var xhr = new XMLHttpRequest();
xhr.responseType = 'blob';
xhr.onload = function(event) {
var blob = xhr.response;
};
xhr.open('GET', url);
xhr.send();
});
setToReadDatafb(output)
}, [])
console.log(toReadfb)
来自 ```toReadfb``` 的日志:
{"_1": 0, "_2": 0, "_3": null, "_4": null}
[1]: https://i.stack.imgur.com/v6uWF.png
英文:
I got the following error:
FirebaseError: Firebase Storage: Object 'Bakery/Bakery Cuisine' does not exist. (storage/object-not-found)
But last I checked:
The path is there and I just uploaded a file in like 30 mins ago. So how come firebase storage is saying it does not exist?
What I want to do: To be able to download the content insid all the .txt files under the path of paramKey
and then display out that content for users to see.
Code:
const [toReadfb, setToReadDatafb] = useState([])
useEffect (() => {
const rfb = sRef(storage, paramKey)
const output = getDownloadURL(rfb)
.then(function (url) {
var xhr = new XMLHttpRequest();
xhr.responseType = 'blob';
xhr.onload = function(event) {
var blob = xhr.response;
};
xhr.open('GET', url);
xhr.send();
});
setToReadDatafb(output)
}, [])
console.log(toReadfb)
My logs from toReadfb
{"_1": 0, "_2": 0, "_3": null, "_4": null}
答案1
得分: 1
Bakery/Bakery Cuisine
在你的截图中是一个文件夹,不是一个文件。无法获取文件夹的下载URL。
Post60e...5ea
在你的截图中是一个文件。如果你想获取该文件,你需要传递它的完整路径(如:Bakery/Bakery Cuisine/Post60e...5ea
)。
如果你想获取文件夹中文件的列表,请查阅Firebase文档上关于列出文件的部分。
英文:
The Bakery/Bakery Cuisine
in your screenshot is a folder, not a file. There is no way to retrieve the download URL of a folder.
The Post60e...5ea
in your screenshot is a file. If you want to retrieve that file, you'll need to pass its entire path (so: Bakery/Bakery Cuisine/Post60e...5ea
).
If you want to get a list of the files in a folder, have a look at the Firebae documentation on listing files.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论