在 React-Native 中使用 AWS Amplify 显示来自 S3 的图像

BHa*_*y82 6 amazon-s3 amazon-web-services react-native aws-amplify

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

state = {
    image: ''
}

async getImage(image) {
    let imageReturn = await Storage.get('9807139f-e5b4-428e-8dfb-d7cfeebe87ab.jpeg')
    this.setState({
        image: imageReturn
    })
}
Run Code Online (Sandbox Code Playgroud)

我已经尝试以两种不同的方式渲染图像,使用 react-native 的 Image 和使用 'aws-amplify-react-native' S3Image。

<Image source={this.state.image} style={{ width: 100, height: 100 }}/>
Run Code Online (Sandbox Code Playgroud)

<S3Image key={'9807139f-e5b4-428e-8dfb-d7cfeebe87ab.jpeg'} />
Run Code Online (Sandbox Code Playgroud)

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

Abo*_*P S 6

AWS 获取返回图像 URL,图像 URL 打印 必须添加uri。请重新连接您的代码 Snippes 是

<Image source={uri:this.state.image} style={{ width: 100, height: 100 }}/>
Run Code Online (Sandbox Code Playgroud)