首页 > 解决方案 > 下载 URL 和图像 URL 之间的区别

问题描述

我将用户个人资料图像存储在 firebase 中。Firebase 将这样的网址返回给我https://firebasestorage.googleapis.com/v0/b/offere-5ad35.appspot.com/o/USERS%2Fqy5SNzVlI7ZNIFeWVnNSZfv1cy22%2Fprof_picture.jpg?alt=media&token=61fab7ff-8f1d-46fb- a1e2-5ffc8be0b00e

这似乎是下载图像而不是在浏览器中显示它。这意味着我不能在我的 React Native 图像标签中使用它。有没有办法将其转换为普通的图像资源 URL。

还是我必须手动获取它并将其存储在设备上?

标签: imagefirebasereact-nativereact-native-firebase

解决方案


我在这里绊倒了自己。

问题是我试图设置<Image source={url} />,并且我收到控制台警告“尝试为 Image 组件设置无效的源。

问题不在于 url 无效,而在于我应该一直使用这种语法

<Image source={{uri: https://firebasestorage.googleapis.com/v0/b/offere-5ad35.appspot.com/o/USERS%2Fqy5SNzVlI7ZNIFeWVnNSZfv1cy22%2Fprof_picture.jpg?alt=media&token=61fab7ff-8f1d-46fb-a1e2-5ffc8be0b00e.}}


推荐阅读