7

我无法让我的图像渲染。我将受保护的图像上传到 S3,没问题。然后我使用下面的代码来检索图像。当我记录 imageReturn 时,我得到带有令牌的图像 URL。

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'} />

任何和所有的帮助表示赞赏。谢谢!

4

1 回答 1

7

AWS 获取返回图片 URL,图片 URL 打印必须加uri。请重新接线您的代码片段是

<Image source={uri:this.state.image} style={{ width: 100, height: 100 }}/>
于 2018-05-19T09:05:12.213 回答