storage.createFile() not uploading, get undefined or network request failed
- 0
- Android
- React Native
- Apple
- Storage
Hi there, please if anybody can, help me to solve this ridiculous issue.
So, I pick an image file with this code (image 1) it works perfectly by giving back this object:
{"assetId": null, "base64": null, "duration": null, "exif": null, "fileName": "1000021004.jpg", "fileSize": 1733865, "height": 3200, "mimeType": "image/jpeg", "rotation": null, "type": "image", "uri": "file:///data/user/0/host.exp.exponent/cache/ExperienceData/%2540anonymous%252Fdonify-cff8f0d0-4436-4e0c-a7f7-f1ce3e30de03/ImagePicker/1b176a9b-93fb-4645-9a2f-af1dc1932e64.jpeg", "width": 1440}
Then it gets passed on to the uploadFile functun, where it was supposed to be uploaded to my storage in Appwrite (image 2)
The storage.createFile() func doesn't seem to be working. I have stripped my whole code down just to try to upload an image hard-coded, I deleted the mimeType assets and tried just the filepath, I tried to hard-code the name, size, type and uri of the file as well. I always and every time get back the same 'undefined'.
I am also logged in within my app with a user, and gave all the necessary permissions for a file upload.
And then if I try to pick an image with the expo-document-picker, when it gets to uploading it, is gives me promise rejection, Error: AppwriteException: Network request failed.
I think asset is null since you have not set it?
Or at least it's not set in the parts of the code that you sent
It's definitely set. It gives back this object when I log it:
{"assetId": null, "base64": null, "duration": null, "exif": null, "fileName": "1000021004.jpg", "fileSize": 1733865, "height": 3200, "mimeType": "image/jpeg", "rotation": null, "type": "image", "uri": "file:///data/user/0/host.exp.exponent/cache/ExperienceData/%2540anonymous%252Fdonify-cff8f0d0-4436-4e0c-a7f7-f1ce3e30de03/ImagePicker/1b176a9b-93fb-4645-9a2f-af1dc1932e64.jpeg", "width": 1440}
Coming from result.assets[0] and then that's the 'file' argument in the uploadFile(file)
Ahhhh, I've just found a similar topic on here and it solved it. I just had to distribute the assets object to this: { name: asset.name, type: asset.mimeType, size: asset.size, uri: asset.uri }
I'm working on A reactNative app, when trying to create a new Entry. The bellow code works only on IOS but on Android I have the AppwriteException : Network request failed
export const createEntry = async () => {
try {
const newEntry = await databases.createDocument(
databaseId,
productCollectionId,
ID.unique(),
{
}
);
return newEntry;
} catch (error) {
throw new Error(error);
}
};
Having the same error on Android.
The code is working perfectly on IOS but on Android I have the AppwriteException: Nextwork request failed.
if there is any possible fix, please share
Recommended threads
- apple exchange code to token
hello guys, im new here 🙂 I have created a project and enabled apple oauth, filled all data (client id, key id, p8 file itself etc). I generate oauth code form...
- Deep Linking & Password reset
I am using react native with expo. I want to implement deep link with the url recived via email. So when clicked the link it opens my app. I havent ever used de...
- Need Help with Google OAuth2 in Expo usi...
I'm learning React Native with Expo and trying to set up Google OAuth2 with Appwrite. I couldn't find any good docs or tutorials for this and my own attempt did...