i am trying to upload file from my mobile device to storage appwrite using react native but still i am not bale to do so..
(Aslo i am running my laptop and mobile on same network ) and my appwrite storage code import { Client, ID, Storage } from "react-native-appwrite"; const client = new Client(); client .setEndpoint("https://cloud.appwrite.io/v1") .setProject("665ee812000a06336853"); const storage = new Storage(client); const uploadImage = async (image) => { try { console.log('Uploading image:', image.name) const response = await fetch(image.uri); console.log('Fetch response status:', response.status);
const blob = await response.blob(); console.log('Blob size:', blob.size);
const file = new File([blob], image.name, {
type: blob.type,
});
console.log('File created:', file);
const result = await storage.createFile(
'66673d8a0009ad6cccb7',
ID.unique(),
file
);
console.log('File uploaded:', result);
return result.$id;
} catch (error) { console.error('Error uploading image:', error); throw error; } };
export const uploadImages = async (images) => { try { console.log('Uploading images:', images.length);
const fileIds = await Promise.all(images.map(uploadImage));
console.log('Uploaded file IDs:', fileIds);
return fileIds;
} catch (error) { console.error('Error uploading images:', error); throw error; } }; and my output is LOG Uploading images: 1 LOG Uploading image: 1000135179.jpg LOG Fetch response status: 200 LOG Blob size: 97953 LOG File created: {"_data": {"__collector": {}, "blobId": "c79ada6f-f8e9-42bc-80d8-d2dace6ed1d9", "lastModified": undefined, "name": "1000135179.jpg", "offset": 0, "size": 97953, "type": "image/jpeg"}} ERROR Error uploading image: [AppwriteException: Network request failed] ERROR Error uploading images: [AppwriteException: Network request failed] ERROR [AppwriteException: Network request failed]
Recommended threads
- How to stop my project from being frozen...
So we encountered an error in production because our appwrite project had been frozen due to inactivity. Is there any way of automating checking in and activity
- Media Pending Files stuck in "Pending" s...
I am a paid member. Region: fra (Frankfurt) Project ID: 66916217002fceb5f94a Bucket ID: 66916727001f0f578e3b Stuck File IDs: screen-20250623-135815.mp4 (and oth...
- ImputFile issue
Why am I getting this error. Please help