【发布时间】:2020-11-25 06:02:20
【问题描述】:
如果我需要从文件夹中获取图片 url,那么我会执行以下操作:
const ref = storage().ref('foldername');
ref
.listAll()
.then(function (result) {
result.items.forEach(function (imageRef) {
// And finally display them
displayImage(imageRef);
});
})
.catch(function (error) {
console.log(error);
// Handle any errors
});
function displayImage(imageRef) {
imageRef
.getDownloadURL()
.then(function (url) {
// TODO: Display the image on the UI
console.log('urlurlurlurl', url);
})
.catch(function (error) {
// Handle any errors
});
}
但我需要先获取文件夹名称列表才能在应用程序中显示它们的名称。
例如 - 我的存储桶包含 3 个文件夹。每个文件夹包含 5 张图片。
我需要先获取这 3 个文件夹的列表。
我正在尝试寻找答案here,但找不到。
谢谢
更新: 这是我的带有 2 个目录的存储桶。这两个目录有图像文件
我需要先获取这些目录名称,以便在屏幕上显示它们。然后我会根据客户端的目录选择来获取文件。
【问题讨论】:
标签: firebase react-native google-cloud-platform firebase-storage react-native-firebase