[英]listRef.listAll() function is undefined (react-native-firebase)
I am trying to get the list of images in a directory from firebase storage.我正在尝试从 firebase 存储获取目录中的图像列表。
Example I want to get all image in users/userid/images , but it does not work and popup an error which the function is undefined.示例我想获取users/userid/images 中的所有图像,但它不起作用并弹出函数未定义的错误。
const listRef = storageRef.child('users/userid/images');
listRef.listAll().then(res=>{
res.items.forEach(itemRef=>{
// console.log(itemRef);
});
}).catch(e =>{});
The ability to list files in a storage bucket wasn't added until version 6.1.0 of the JavaScript SDK .直到JavaScript SDK 6.1.0 版才添加了在存储桶中列出文件的功能。 So make sure your SDK is up to date.
因此,请确保您的 SDK 是最新的。
And now we can do it as well, thnk you from react-native-firebase
team.现在我们也可以做到了,感谢来自
react-native-firebase
团队的您。
const reference = storage().ref('images');
const getListOfImages = async (){
const res = await reference.child('profileimages').list();
return await Promise.all(res.items.map(i => i.getDownloadURL()));
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.