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

标签 amazon-web-services react-native amazon-s3 aws-amplify

我无法渲染我的图像。我将 protected 图像上传到 S3,没问题。然后我使用下面的代码来检索图像。当我记录 imageReturn 时,我得到带有 token 的图像 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'} />

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

最佳答案

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

<Image source={uri:this.state.image} style={{ width: 100, height: 100 }}/>

关于amazon-web-services - 在 React-Native 中使用 AWS Amplify 显示来自 S3 的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50421114/

相关文章:

amazon-web-services - .dockercfg文件应如何托管在AWS上的Mesosphere设置中,以便只有Mesosphere可以使用它?

amazon-web-services - EventBridge PutEvents 的基于标签的策略

reactjs - 在 native react 中检测 View 外部的点击

javascript - React Native - PropTypes.bool 中的 "Cannot read property ' bool' 未定义

react-native - 订阅 Redux 中 store 中的单个属性更改

ruby-on-rails - AWS::Errors::MissingCredentialsError in LocationsController#create 使用回形针和 aws Gem

python-2.7 - Boto3 下载文件中的 IOError

python - 端点 URL : https://sns. us-west-1.amazonaws.com 上的连接超时

json - 在身份验证之前在 AWS 构建规范中使用 jq - 最佳实践?

amazon-web-services - 如何使用 Amazon Cognito 作为我的网站(而非移动应用程序)的用户身份验证