async _getPhoto(){ const image = await ImagePicker.launchImageLibraryAsync({quality:0.3}) this.props.photo(image.uri) this.setState({image:image}) }
async onPickFileButtonPressed(context) { let result; let permission = await Permissions.getAsync(Permissions.CAMERA_ROLL); if (!permission.granted) { permission = await ImagePicker.requestCameraRollPermissionsAsync({base64: false, exif: false}); if (permission.granted) { result = await ImagePicker.launchImageLibraryAsync(); if (!result.cancelled) context.updateStateProperty("file", result.uri); } } else { result = await ImagePicker.launchImageLibraryAsync(); if (!result.cancelled) context.updateStateProperty("file", result.uri); } }
const pickFromGallery = async ()=>{ const {granted} = await Permissions.askAsync(Permissions.CAMERA_ROLL) if(granted){ let data = await ImagePicker.launchImageLibraryAsync({ 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 user = firebase.auth().currentUser const handleUpload = async () => { const result = await ImagePicker.launchImageLibraryAsync() const split = result.uri.split('/') const fileName = split[split.length - 1]
async onPickFileButtonPressed(context) { let result; let permission = await Permissions.getAsync(Permissions.CAMERA_ROLL); if (!permission.granted) { permission = await ImagePicker.requestCameraRollPermissionsAsync({base64: false, exif: false}); if (permission.granted) { result = await ImagePicker.launchImageLibraryAsync(); if (!result.cancelled) { let newPassportForm = context.state.passportForm; newPassportForm.file = result.uri.toString(); context.updateStateProperty("passportForm", newPassportForm); } } } else { result = await ImagePicker.launchImageLibraryAsync(); if (!result.cancelled) { let newPassportForm = context.state.passportForm; newPassportForm.file = result.uri.toString(); context.updateStateProperty("passportForm", newPassportForm); } } }