uppy/examples/react-native-expo/react-native/file-picker/selectImage.js
2019-03-15 13:20:17 +03:00

22 lines
585 B
JavaScript

import * as 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