ERROR Create file error, uploadImage: [TypeError: Cannot read property 'size' of undefined]
- 0
- React Native
- Storage
Hi, I am using React-native and appwrite for my project. I am trying to upload an image to Appwrite storage bucket but receiving error while creating and uploading the file. ERROR Create file error, uploadImage: [TypeError: Cannot read property 'size' of undefined]. Please help me with correct approach to store the image to bucket. The code I am using is provided below and frontend and console response is attached in the file.
Backend.js const uploadImage = async (imagefile) => { if (!imagefile) { console.error('No file provided for upload.'); return; }
console.log('File to Upload:', imagefile);
const asset = { name: imagefile.fileName, type: imagefile.type, size: imagefile.fileSize, uri: imagefile.uri, }; console.log('Prepared File for Upload:', asset); try { const uploadedFile = await storage.createFile( BUCKET_ID_IMAGE, ID.unique(), asset, ); console.log('Uploaded file:', uploadedFile);
return uploadedFile;
} catch (error) { console.error('Create file error, uploadImage:', error); throw error; } };
Recommended threads
- Need help in email verification - react ...
Hi, i am trying to verify user, but it is asking me a redirect link, and as i am creating an mobile app, i want it to be done in the app itself. Please if anybo...
- Storage usage keeps going up
I have a self-hosted instance running in production for over a year now. The deployment has seen multiple updates and migrations of Appwrite versions. What I ha...
- SSR Image Previews
I am using the SSR guide (with SvelteKit) to use Appwrite on both the server and the client. I do this by also passing the cookie back to the client and creatin...