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