【问题标题】:Get URL of file after uploading to Firebase with React Native and Expo使用 React Native 和 Expo 上传到 Firebase 后获取文件的 URL
【发布时间】:2018-09-04 07:37:01
【问题描述】:

在我的 expo 项目中,我可以将图像上传到 firebase 并可以从我的 firebase 控制台查看,但我想获取该上传图像的 url 如何获取我的上传功能的 url。

uploadImage = async (uri, imageName) =>{
  const response = await fetch(uri);
  const blob = await response.blob();
  // calling firebase storage api
  var ref = Firebase.storage().ref().child("images/posts/"+imageName);
  console.log("*****************firebase***************")
  console.log(ref)
  console.log("*****************firebase***************")
  return ref.put(blob);

}

【问题讨论】:

    标签: firebase react-native firebase-storage expo


    【解决方案1】:

    您可以直接在您的存储参考上使用getDownloadUrl 方法以promise

    的形式获得结果
    ref.getDownloadURL().then((url) => console.log(url))
    

    【讨论】:

    • 如何使用url值并在<Tex>中显示?
    猜你喜欢
    • 2021-11-30
    • 2020-04-18
    • 2021-06-07
    • 2022-06-21
    • 2019-10-11
    • 2022-07-21
    • 1970-01-01
    • 2020-04-23
    • 2021-09-22
    相关资源
    最近更新 更多