
async uploadProfilePicture(fileUri: string, phoneNumber: string) {
try {
// Get the file extension and use it to create the file name
const fileType = fileUri.split('.').pop();
const fileName = ${phoneNumber}.${fileType}
;
// Fetch the file data from the URI
const response = await fetch(fileUri);
if (!response.ok) {
throw new Error('Failed to fetch the image file.');
}
const fileBlob = await response.blob();
// Create a new File object without explicitly setting the MIME type
const file = await storage.createFile(
'66d17e5b0023edd74cde', // Replace with your bucket ID
ID.unique(),
new File([fileBlob], fileName)
);
return file; // Returns the file metadata
} catch (error: any) {
console.error('Error uploading profile picture:', error);
if (error.message.includes('Network request failed')) {
Alert.alert('Network Error', 'Please check your internet connection and try again.');
} else {
Alert.alert('Upload Error', 'There was an error uploading your profile picture. Please try again.');
}
throw error; // Rethrow the error after handling it
}
} This is showing following error [Appwrite exception:Network Request Failed] Please help

[Appwrite exception:Network Request Failed]
Recommended threads
- React native Google OAuth not working - ...
## Code: *Pretty much just copied from appwrite docs* ```javascript const signInWithOAuth = async (provider) => { setLoading(true); try { // Crea...
- AVIF file format as default
In appwrite, is it possible that whenever a user uploads an image it gets converted to a specific format for eg AVIF always? I know I can use cloud functions bu...
- Receive messages in an Android app
> https://appwrite.io/docs/products/messaging/send-push-notifications in this doc there is not provide the how to receive cloud messages from fmc so i have edi...
