const pickFromCamera = async ()=>{ const {granted} = await Permissions.askAsync(Permissions.CAMERA) if(granted){ let data = await ImagePicker.launchCameraAsync({ mediaTypes:ImagePicker.MediaTypeOptions.Images, allowsEditing:true, aspect:[1,1], quality:0.5 }) if(!data.cancelled){ let newfile = { uri:data.uri, type:`test/${data.uri.split(".")[1]}`, name:`test.${data.uri.split(".")[1]}` } handleUpload(newfile) } }else{ Alert.alert("you need to give up permission to work") } }
const PhotoPicker = ({ onPick }) => { const [image, setImage] = useState(null); const takePhoto = async () => { const hasPermissions = await askForPermissions(); if (!hasPermissions) { return; } const img = await ImagePicker.launchCameraAsync({ quality: 0.7, allowsEditing: false, aspect: [16, 9], }); setImage(img.uri); onPick(img.uri); }; return ( <View style={styles.wrapper}> <Button title="To make a photo" onPress={takePhoto} /> {image && <Image style={styles.image} source={{ uri: image }} />} </View> ); }
const image = await ImagePicker.launchCameraAsync({ allowsEditing: true, aspect: [16, 9],