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
- Need help with STORAGE (no tutorials onl...
```javascript const uploadPage = () => { const [file, setFile] = useState<File | null>(null); const handleFileChange = (e:any) => { setFile(e.t...
- OTP SMS Template
Hello, Up until about a week ago, the OTP SMS read: "Your SMS verification code is: <code>” For the past few days, the SMS only contains the six-digit code. Is ...
- Error while trying to use custom domain ...
Hello! I tried to use my connected custom domain to setup user verify email link but received an error. In my Android code, i send request to verification: ``` ...