首页 > 解决方案 > 我们如何列出firebase存储中的所有文件夹

问题描述

firebase 存储的官方文档没有规定显示文件夹,它只提供file。那么在这种情况下我该怎么办。

标签: javascriptfirebase-storage

解决方案


这是不正确的 - 它确实允许您显示嵌套前缀(您称之为文件夹)。文档在提供的示例代码中清楚地说明了这一点:

listRef.listAll().then(function(res) {
  res.prefixes.forEach(function(folderRef) {
    // All the prefixes under listRef.
    // You may call listAll() recursively on them.
  });
  res.items.forEach(function(itemRef) {
    // All the items under listRef.
  });
}).catch(function(error) {
  // Uh-oh, an error occurred!
});

上面,res.prefixes包含嵌套在列出的前缀下的前缀列表。请注意,我使用了正确的术语“前缀”。云存储实际上没有“文件夹”。


推荐阅读