Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

App crashes on iOS when trying to upload image to firebase storage using react native

$
0
0

to pick the image i usedimport * as ImagePicker from 'expo-image-picker';

image pick process

        const permission = await ImagePicker.requestMediaLibraryPermissionsAsync();        if (permission.granted === false) {            Alert.alert('You did not accept access to internal storage');        } else {            console.log(permission);            const result = await ImagePicker.launchImageLibraryAsync({                mediaTypes: ImagePicker.MediaTypeOptions.All,                allowsEditing: true,                aspect: [4, 3],                quality: 1,            });            console.log(result);                if (!result.cancelled) {                    const imageToUploadUri = result.uri;                    setImage(imageToUploadUri);                    Alert.alert('picture loaded now upload it to the storage');                } else {                    Alert.alert('You did not chose any image');                }        }    };

and the image is set successfully but when i am try to upload this image to firebase storage the app crash only on ios.

the firebase imports i used:

import firebase from 'firebase/compat/app';import { getDownloadURL, getStorage, ref, uploadBytes } from 'firebase/storage';
// image upload functionexport const uploadImage  = async (url: string, clubName: string) => {      const storage = getStorage();    const reffernce = ref(storage, `home_image/${clubName}_main.png`);    const image = await fetch(url);    const bytes = await image.blob();    await uploadBytes(reffernce, bytes);}

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>