Last active
October 5, 2018 10:18
-
-
Save watanabeyu/0992cf7a6ea7ba5ee5afe714a5473fbc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react'; | |
import { Text, View, StyleSheet,TouchableOpacity,CameraRoll,Linking } from 'react-native'; | |
import { Constants,FileSystem,Permissions } from 'expo'; | |
export default class App extends React.Component { | |
onPress = async () => { | |
const filePath = `${FileSystem.documentDirectory}share-movie.mp4`; | |
const res = await FileSystem.downloadAsync('http://techslides.com/demos/sample-videos/small.mp4', filePath); | |
// const i = await FileSystem.getInfoAsync(res.uri); | |
// console.log(i); | |
const { status } = await Permissions.askAsync(Permissions.CAMERA_ROLL); | |
if (status === 'granted') { | |
try{ | |
const result = await CameraRoll.saveToCameraRoll(res.uri,"video"); | |
Linking.openURL(`instagram://library?AssetPath=${encodeURIComponent(result)}`); | |
} | |
catch(e){ | |
console.warn(JSON.stringify(e)) | |
} | |
} | |
} | |
render() { | |
return ( | |
<View style={styles.container}> | |
<TouchableOpacity onPress={this.onPress}> | |
<Text>download and getinfo</Text> | |
</TouchableOpacity> | |
</View> | |
); | |
} | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
alignItems: 'center', | |
justifyContent: 'center', | |
paddingTop: Constants.statusBarHeight, | |
backgroundColor: '#ecf0f1', | |
}, | |
paragraph: { | |
margin: 24, | |
fontSize: 18, | |
fontWeight: 'bold', | |
textAlign: 'center', | |
color: '#34495e', | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment