PROBLEMS UPLOADING IMAGE IN REACT-NATIVE TO STORAGE ON APPWRITE
- 1
- Databases
- React Native
- Storage
- REST API

having serious problems uploading image from react-native using expo-go to Appwrite storage. #react-native #storageupload #createfile

Can you provide details about what you're doing? And what problem are you having?
Also, what package did you install?

And what's the code?

Alright sir, i am making an app and there is a part to editStore, now i want to be able to upload picture to storage for coverimage and profile picture, i am using reactnative and expo, also i am making use of appwrite, below is my code below, i'll first post the EditStore.jsx in which is the page i use to change the picture;

next is the part of my appwrite code responsible for this;

export const uploadFile = async (fileUri) => { try { console.log("Uploading file:", fileUri); console.log(fileUri); // Ensure file exists const fileInfo = await FileSystem.getInfoAsync(fileUri); if (!fileInfo.exists) { throw new Error("File does not exist at given URI."); } console.log(fileUri.name); const fileInf = { name: fileUri.name, size: fileUri.fileSize, type: fileUri.mimeType, uri: fileUri.uri };
// Upload to Appwrite storage
const uploadedFile = await storage.createFile(
Config.storageId,
ID.unique(),
fileInf // Pass the File object
);
console.log("File uploaded successfully:", uploadedFile);
return uploadedFile.$id;
} catch (error) { console.error("Upload error:", error.message); throw new Error("Upload failed: " + error.message); } };
export const getFilePreview = async (fileId) => { try { return storage.getFilePreview(Config.storageId, fileId, 2000, 2000, "top", 100); } catch (error) { throw new Error("Failed to get image URL: " + error.message); } };

FYI, it's best to wrap code in backticks to format a bit nicer. You can use 1 backtick for inline code (https://www.markdownguide.org/basic-syntax/#code) and 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting).

alright sir

so in my code, the place currently giving me issue is from the uploading to storage aspect, in storage.createFile, its saying cannot read size of undefined and console.log(fileUri.name) does not log anything, it logs undefined

What Appwrite package did you install?
Recommended threads
- updatePassword invalid credentials error...
This is my code: ```js const result = await account.updatePassword( newPassword ); ``` This is my error: ``` [AppwriteException: Invalid cr...
- Network Request Failed
Trying to save a file to the bucket but getting network request failed. Using react-native-image-picker.
- Attribute stuck at processing state
Its been half hour since the attributes are getting stuck in the processing state. When will this get resolved ?
