9

I cannot get my image to render. I upload a protected image to S3, no problem. I then use the below code to retrieve the image. When I log imageReturn I get the image URL with token.

state = {
    image: ''
}

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

I've tried rendering the image two different ways, with react-native's Image and with 'aws-amplify-react-native' S3Image.

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

and

<S3Image key={'9807139f-e5b4-428e-8dfb-d7cfeebe87ab.jpeg'} />

Any and all help is appreciated. Thanks!

BHalvy82
  • 177
  • 1
  • 4
  • 14
  • does that image needs to be private ? or you have to showcase it on web and you can allow anyone to access it ? then i can tell you how to get it like this [link]( https://s3.amazonaws.com/mausamrest/desk.JPG) – Mausam Sharma May 19 '18 at 04:00
  • It needs to be visible by anyone but only editable by the person who uploads it. – BHalvy82 May 19 '18 at 04:02
  • What would you do if you have multiple images and want to select an image based upon which user is currently logged in? – Evan Erickson May 14 '21 at 17:45

1 Answers1

8

AWS get return image URL, Image URL printing Must be added uri . Please Rewire Your code Snippest is

<Image source={uri:this.state.image} style={{ width: 100, height: 100 }}/>
Aboobakkar P S
  • 796
  • 1
  • 8
  • 28