I am trying to convert an image to blob for uploading it to aws s3 storage.I need to connvert image to blob after selecting the image with expo-image-picker the convert to blob using fetch but it is causing the following error.
ERROR RangeError: Failed to construct 'Response': The status provided (0) is outside the range [200, 599]., js engine: hermes
This is my current situation :
import { Button, StyleSheet, Text, View } from 'react-native';
import * as ImagePicker from 'expo-image-picker'
export default function App() {
const PickImage = async()=>{
let result = await ImagePicker.launchImageLibraryAsync({
quality:1,
mediaTypes:ImagePicker.MediaTypeOptions.Images,
})
if(!result.canceled){
let response = await fetch(result.assets[0].uri);
let blob = await response.blob();
//code to upload image
}
}
return (
<View style={styles.container}>
<Button onPress={PickImage} title='TEST'/>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
the fetch ststement is causing error.
let response = await fetch(result.assets[0].uri);
I tried to build it in expo snack and it is working fine. I am not getting any errors.but it is crashing on my local setup.