I'm searching for a document uploader for my app and I got the expo document uploader. But unfortunately when I'm going to test the app and nothings happens. Kindly let me know the solution for this.
Asked
Active
Viewed 79 times
1 Answers
1
Your imports were outdated, importing ImagePicker from expo looks like this:
import * as ImagePicker from 'expo-image-picker';
Additionally, you were not requesting permissions. You should do so like this:
componentDidMount() {
this.getPermissionAsync();
}
getPermissionAsync = async () => {
if (Constants.platform.ios) {
const { status } = await Permissions.askAsync(Permissions.CAMERA_ROLL);
if (status !== 'granted') {
alert('Sorry, we need camera roll permissions to make this work!');
}
}
};
Finally, if an async function seems to be doing nothing try wrapping it in a try/catch block so that you can see why it is failing as a failed promise does not always log correctly. Like this:
_pickImage = async () => {
try {
let result = await ImagePicker.launchImageLibraryAsync({
allowsEditing: true,
aspect: [4, 3],
});
if (!result.cancelled) {
this.setState({ image: result.uri });
}
} catch (e) {
console.log(e);
}
};
Most importantly, you should always consult the documentation when approaching an issue like this. Expo's image picker documentation not only describes the above but gives you a working example.
Here is a modified, working version of your snack

CampbellMG
- 2,090
- 1
- 18
- 27
-
I want to convert the image into byte and then send into to the server through webapi. any example for this? Thanks – Zain Khan Jan 30 '20 at 10:25
-
You can have a look at [this](https://stackoverflow.com/questions/42521679/how-can-i-upload-a-photo-with-expo). However, if you are having trouble with the process I would suggest opening a new question. If my answer helped you with this question, please accept it – CampbellMG Jan 30 '20 at 11:35
-
Okay here is the open question https://stackoverflow.com/questions/59989963/how-do-i-convert-image-uri-into-byte-expo – Zain Khan Jan 30 '20 at 16:03