简体   繁体   English

listRef.listAll() 函数未定义(react-native-firebase)

[英]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.

相关问题 无法从 React-Native-Firebase(v6) Firestore 获取数据:undefined 不是函数(靠近“...this._firestore.native.collectionGet...”) - Can't get data from React-Native-Firebase(v6) Firestore: undefined is not a function (near '...this._firestore.native.collectionGet...') react-native-firebase getInitialNotification循环 - react-native-firebase getInitialNotification loop React-Native-Firebase:RTDB 模拟器 - React-Native-Firebase : RTDB Emulator react-native-firebase重新发送消息代码 - react-native-firebase resend message code iOS 远程通知不起作用 react-native-firebase [v6] - iOS remote notification not working react-native-firebase [v6] iOS 无法在 react-native-firebase 中接收通知 - iOS can't receive notifications in react-native-firebase 使用 react-native-firebase 时添加对 Android 通知的回复 - Add replies to Android notifications while using react-native-firebase 当离线模式处于活动状态时,react-native-firebase 是否安全? - Is react-native-firebase secure when offline mode is active? 二阶通过查询在Firestore中不执行任何操作(react-native-firebase) - Second orderBy query does nothing in Firestore (react-native-firebase) 离线查询上的 React-native-firebase 服务器时间戳 - React-native-firebase server timestamp on offline queries
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM