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
- HTTP Error 500 ''
Hello to everyone, I'm a Flutter developer and actually I'm developing an app using Appwrite.. during my tests and also massive ones I've noticed something we...
- Appwrite rejecting create and edit reque...
hello, so my issue is that when i make a debug build of my app, everything works as it should, but when i download and test a SIGNED release database rejects al...
- Websites hosted on my appwrite sites hav...
Hello, all my websites hosted on appwrite sites are not running I am getting this message "This site can’t be reached drivehub.appwrite.network took too long t...