mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-19 17:44:30 +00:00
25 lines
771 B
JavaScript
25 lines
771 B
JavaScript
import * as Permissions from 'expo-permissions'
|
|
import * as ImagePicker from 'expo-image-picker'
|
|
|
|
function selectImageWithExpo (options) {
|
|
return new Promise((resolve, reject) => {
|
|
// This is a different `Permissions` object than eslint-plugin-compat thinks it is
|
|
// eslint-disable-next-line compat/compat
|
|
return Permissions.askAsync(Permissions.CAMERA_ROLL)
|
|
.then((isAllowed) => {
|
|
if (!isAllowed) {
|
|
return reject(new Error('Permissions denied'))
|
|
}
|
|
|
|
return ImagePicker.launchImageLibraryAsync(options)
|
|
.then((result) => {
|
|
console.log(result)
|
|
if (!result.cancelled) {
|
|
return resolve(result)
|
|
}
|
|
})
|
|
})
|
|
})
|
|
}
|
|
|
|
export default selectImageWithExpo
|