【发布时间】:2021-12-18 15:44:17
【问题描述】:
我正在开发一个页面并使用 firebase 存储作为文件存储。我尝试在 firebase 开发人员文档中使用给定的代码,但我似乎无法使其工作。可能是什么问题?
document.getElementById("but").addEventListener('click', e => {
// Create a reference under which you want to list
const listRef = ref(storage, 'folder/');
// Find all the prefixes and items.
listAll(listRef)
.then((res) => {
res.prefixes.forEach((folderRef) => {
// All the prefixes under listRef.
// You may call listAll() recursively on them.
});
res.items.forEach((itemRef) => {
// All the items under listRef.
console.log( getDownloadURL(ref(storage, `folder/${itemRef}`)))
})
})
});
【问题讨论】:
-
请阅读 Firebase 文档firebase.google.com/docs/database/web/…
-
“我似乎无法让它工作” 您共享的代码有什么问题?如果有错误,请在您的问题中分享错误消息和堆栈跟踪。如果没有错误,在每一行设置断点并在调试器中运行代码。哪一行是第一个不符合您预期的行?
标签: javascript firebase firebase-storage