
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
- I am getting a 401 unauthorized response...
I have a Next.js application that stores user PDFs. I'm able to save them normally, but when trying to access the files using getFileView, I get a 401 Unauthori...
- Google OAuth2 screen loop issue in Flut...
i am trying to authenticate user on my app using google, everything works fine, but even after succesfull authentication instead of redirecting back to the app,...
- Failed to Fetch : Uploading to Storage
i am trying to upload an .csv file and a .npz file to bucket on Appwrite console. one is 14mb and the other 18mb. I have tried several times with failed to fetc...
