Back
[AppwriteException: Network request failed] while creating file to storage in react native
- 0
- React Native

TypeScript
const onUpload = async (fileUri: string, filename: string) => {
try {
console.log('fileUri: ', fileUri);
console.log('filename: ', filename);
const response = await fetch(fileUri);
const blob = await response.blob();
const file = new File([blob], filename, {
type: blob.type,
lastModified: Date.now(),
});
console.log('file: ', file);
const updatedUser = await AppwriteService.storage.createFile(
appwriteConfig.appwiteBucketId!,
ID.unique(),
file,
);
if (updatedUser) {
Snackbar.show({
text: 'Profile picture updated',
textColor: 'white',
backgroundColor: 'green',
});
}
} catch (error) {
console.log('error: ' + error);
Snackbar.show({
text: 'Something went wrong',
textColor: 'white',
backgroundColor: 'red',
});
}
};
Console:
TypeScript
LOG fileUri: file:///data/user/0/com.realtimechatapp/cache/rn_image_picker_lib_temp_12b45e47-2616-4563-9dba-01624184d597.jpg
LOG filename: 1000000033.jpg
LOG file: {"_data": {"__collector": {}, "blobId": "b8696e98-a0c4-4c9e-a4b0-745944dc7d91", "lastModified": 1721107789711, "name": "1000000033.jpg", "offset": 0, "size": 143439, "type": "image/jpeg"}}
LOG error: AppwriteException: Network request failed
TL;DR
Developers are encountering a `Network request failed` error when trying to create a file in storage using React Native. The error occurs during the fetch operation. Ensure the network connection is stable and the file's URI is correct.Recommended threads
- Stuck at pinging the server to finish ad...
I'm not using the starter app and I'm not sure how to finish connecting my app to Appwrite.io. Is there a CURL command I can run to finish setup?
- Trouble with emailVerification(appname:/...
[AppwriteException: Invalid `url` param: Invalid URI. Register your new client (app) as a new platform on your project console dashboard]. i previously had ema...
- 500Internal Error
console errors fra.cloud.appwrite.io/v1/console/variables:1 Failed to load resource: net::ERR_CERT_COMMON_NAME_INVALID console.js:36 TypeError: Failed to fetch...
