Last active
January 22, 2020 19:25
-
-
Save alejovdev/6ab6d2be61520fe101a76cfccaed612f 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
const pickImage = async () => { | |
let result = await ImagePicker.launchCameraAsync({ | |
mediaTypes: ImagePicker.MediaTypeOptions.Images, | |
allowsEditing: true, | |
aspect: [1, 1], | |
quality: 1, | |
base64: true | |
}) | |
if (!result.cancelled){ | |
// I'm adding the data:image, if you want to use the image locally before uploading, you can use a state hook first | |
uploadImage('data:image/png;base64,' + result.base64) | |
} | |
} | |
const uploadImage = async data_url => { | |
let upload = functions.httpsCallable('uploadExpoImage') | |
let res = await upload({ | |
data_url: data_url, | |
path: `alejov/images` //Replace with the location where you want your image | |
}) | |
if (typeof res.data === 'string') url = res.data | |
// Now you have url that is whatever you returned from uploadExpoImage | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment