After updating to RN 0.50 and sdk 23.00, i’m getting an issue with FileAsync
when the image is taken, i send the object to this function, where i get error at the line
let res = await Expo.FileSystem.getInfoAsync(fileUri, options);
and returns the error:
Possible Unhandled Promise Rejection (id: 0):
Error: Location ‘file:///file%3A/data/user/0/host.exp.exponent/cache/ExperienceData/%252540anonymous%25252Fsafegive-32c36181-4cb7-4757-acf6-0ee918f1eba5/ImagePicker/1688a6b5-929e-486f-aa15-cffb5429329c.jpg’ isn’t readable.
createErrorFromErrorData@http://192.168.2.111:19001/./node_modules/react-native-scripts/build/bin/crna-entry.bundle?platform=android&dev=true&minify=false:3255:24
http://192.168.2.111:19001/./node_modules/react-native-scripts/build/bin/crna-entry.bundle?platform=android&dev=true&minify=false:3208:49
__invokeCallback@http://192.168.2.111:19001/./node_modules/react-native-scripts/build/bin/crna-entry.bundle?platform=android&dev=true&minify=false:3566:21
http://192.168.2.111:19001/./node_modules/react-native-scripts/build/bin/crna-entry.bundle?platform=android&dev=true&minify=false:3383:32
__guard@http://192.168.2.111:19001/./node_modules/react-native-scripts/build/bin/crna-entry.bundle?platform=android&dev=true&minify=false:3501:11
invokeCallbackAndReturnFlushedQueue@http://192.168.2.111:19001/./node_modules/react-native-scripts/build/bin/crna-entry.bundle?platform=android&dev=true&minify=false:3382:19
invokeCallbackAndReturnFlushedQueue@[native code]
async _handleImagePicked(pickerResult){
options={
md5:false
};
let uploadResponse, uploadResult;
let fileUri = pickerResult.uri;
let res = await Expo.FileSystem.getInfoAsync(fileUri, options);
let size=((res.size/1024)/1024).toFixed(2);
if(size<=1.52){
try {
//this.setState({ uploading: true });
if (!pickerResult.cancelled) {
uploadResponse = await this.uploadImageAsync(pickerResult.uri);
uploadResult = await uploadResponse.json();
if(uploadResult.success===true){
Alert.alert("Atenção", uploadResult.message);
// console.log("resposta ",pickerResult.uri);
AuthStore.user.avatar=uploadResult.data.link;
// console.log(uploadResult.data.link);
AuthStore.setUser(AuthStore.user);
AppViewStore.avatar = AuthStore.user.avatar;
options={};
AsyncStorage.setItem(AVATARKEY, AppViewStore.avatar)
this.setState({uploading:false});
}
else
{ this.setState({uploading:false});
Alert.alert("Atenção ",uploadResult.error.errors.image.toString());
}
}
} catch (e) {
this.setState({uploading:false});
alert('Falha ao enviar a imagem.');
}
}
else
{
Alert.alert(“Atenção”,'O tamanho máximo da imagem é 1.5Mb. Sua Imagem: '+size+‘Mb’);
this.setState({uploading:false});
}
}
And here is my ImagePicker result
PICKER RESULT Object {
“cancelled”: false,
“height”: 3328,
“type”: “image”,
“uri”: “file:///file%3A/data/user/0/host.exp.exponent/cache/ExperienceData/%252540anonymous%25252Fsafegive-32c36181-4cb7-4757-acf6-0ee918f1eba5/ImagePicker/0f87b646-9235-4e17-b811-1115ffec2eca.jpg”,
“width”: 2496,
}