uppy/examples/react-native-expo/react-native/file-picker/selectImage.js
2018-12-19 15:45:48 +03:00

22 lines
580 B
JavaScript

import Expo from 'expo'
function selectImageWithExpo (options) {
return new Promise((resolve, reject) => {
return Expo.Permissions.askAsync(Expo.Permissions.CAMERA_ROLL)
.then((isAllowed) => {
if (!isAllowed) {
return reject(new Error('Permissions denied'))
}
return Expo.ImagePicker.launchImageLibraryAsync(options)
.then((result) => {
console.log(result)
if (!result.cancelled) {
return resolve(result)
}
})
})
})
}
export default selectImageWithExpo