Skip to content

Instantly share code, notes, and snippets.

@dabit3 dabit3/App.js
Created Mar 5, 2018

Embed
What would you like to do?
Amplify S3 example
import React, { Component } from 'react';
import {
StyleSheet,
Text,
Button,
View,
Image
} from 'react-native';
import Amplify, { Storage } from 'aws-amplify'
import config from './aws-exports'
Amplify.configure(config)
// window.LOG_LEVEL='DEBUG'
export default class App extends Component {
state = {
url: ''
}
async getFile() {
let name = 'example-image.png';
let fileUrl = await Storage.get(name);
this.setState({
url: fileUrl
})
}
render() {
return (
<View style={styles.container}>
<Text>Storage</Text>
<Button
title="Get Image"
onPress={this.getFile.bind(this)}
/>
{
this.state.url !== '' && (
<Image
source={{ uri: this.state.url }}
style={{ width: 300, height: 300 }}
/>
)
}
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.