简体   繁体   English

无法查看firebase存储中的图片

[英]I can't view the picture in the firebase storage

my get code我的获取码

` getImage = async (imageUrl) => {
    const user = firebase.auth().currentUser;
    const url = await storage()
        .ref(`Users/${user.uid}/picture`)
        .getDownloadURL()
    console.log(url)
    imageUrl = url;
    let imgSource = { uri: imageUrl }; // change this line
    if (isNaN(imageUrl)) {
      imgSource = { uri: this.state.imageUrl };
      if (Platform.OS == 'android') {
        imgSource.uri = "file:///" + imgSource.uri;
      }
    }
    
}


  render() {

    let {imageUrl} = this.state;

    return (
        <View>
             <Image source={this.getImage(imageUrl)} style={{width:200,height:200}}/> 
        </View>

` console screenshot I can get the url from my console but the picture is not showing in my app, what's the problem ` console screenshot我可以从我的控制台获取 url 但图片没有显示在我的应用程序中,这是什么问题

This might help这可能有帮助

state = { newImageURL : undefined }

getImage = async (imageUrl) => {
    const user = firebase.auth().currentUser;
    const url = await storage()
        .ref(`Users/${user.uid}/picture`)
        .getDownloadURL()
    console.log(url)
    imageUrl = url;
    let imgSource = { uri: imageUrl }; // change this line
    if (isNaN(imageUrl)) {
      imgSource = { uri: this.state.imageUrl };
      if (Platform.OS == 'android') {
        imgSource.uri = "file:///" + imgSource.uri;
      }
    }
    this.setState({ newImageURL: imgSource }); // update code here
    
}

componentDidMount(){
  let {imageUrl} = this.state;
  this.getImage(imageUrl)
}


  render() {
    return (
        <View>
             {newImageURL ? <Image source={newImageURL} style={{width:200,height:200}}/> : null }
        </View>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Firebase 存储无法连接,重试 - Firebase Storage Can't Connect, Retry again 如何上传 PDF Firebase 存储? - How can I upload a PDF Firebase Storage? 如何在firebase存储中上传一张图片,在firebase文档字段中获取url - How to upload a picture in firebase storage and get it url in firebase document field 无法通过 web 上的 Firebase 存储访问上传的文件 - Can't access uploaded files through Firebase storage on web firebase存储出错是否可以继续上传? - Can I resume the uploading if an error occurs in firebase storage? 如何从 Firebase 存储中删除图像??(反应) - How can I delete images from Firebase Storage??(react) 如何在 React js 中从 firebase 存储下载文件? - How can I download a file from firebase storage in react js? 如何为 firebase 存储中具有已知路径的图片获取可重用的 url? - How to get reusable url for a picture in firebase storage that has a known path? 我如何判断它是图像还是视频 - Firebase Storage/Firestore - How can I tell if it's an image or video - Firebase Storage/Firestore 如何在 Firebase 存储(颤振)中的文件更改时重建个人资料图片小部件 - How to rebuild profile picture widget on changes to file in Firebase Storage (Flutter)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM