我无法渲染我的图像。我上传受保护的图像到S3,没问题。然后我使用下面的代码来检索图像。当我记录imageReturn时,我得到带有令牌的图片网址。
state = {
image: ''
}
async getImage(image) {
let imageReturn = await Storage.get('9807139f-e5b4-428e-8dfb-d7cfeebe87ab.jpeg')
this.setState({
image: imageReturn
})
}
我尝试过两种不同的渲染方式,使用react-native的Image和'aws-amplify-react-native'S3Image。
<Image source={this.state.image} style={{ width: 100, height: 100 }}/>
和
<S3Image key={'9807139f-e5b4-428e-8dfb-d7cfeebe87ab.jpeg'} />
感谢任何和所有帮助。谢谢!
答案 0 :(得分:4)
AWS获取返回图片网址,图片网址打印必须添加 uri 。请重新连接您的代码Snippest
<Image source={uri:this.state.image} style={{ width: 100, height: 100 }}/>