![](https://cdn.discordapp.com/avatars/380153049307545604/2cb362b38a8c42d7e4f7a1afc8947e92.webp)
Hi there, I am trying to upload a picture to my storage in appwrite but it is giving me an error as titled. Here is my code:
TypeScript
let fileUrl;
try {
fileUrl = storage.getFilePreview(appwriteConfig.storageId, fileId, 2000, 2000, "top", 100);
if (!fileUrl) throw new Error("Failed to get file preview");
return fileUrl;
} catch (error) {
console.error("Error in getFilePreviewYes:", error);
throw new Error(error);
}
};
export const uploadFile = async (file) => {
if (!file) return;
const asset = { name: file.name, size: file.fileSize, type: file.mimeType, uri: file.uri };
try {
const uploadedFile = await storage.createFile(appwriteConfig.storageId, ID.unique(), asset);
const fileUrl = await getFilePreviewYes(uploadedFile.$id);
return fileUrl;
} catch (error) {
throw new Error(error.message || "Error Uploading File");
}
};
export const createArtwork = async (form) => {
try {
const image = await uploadFile(form.images);
const newArtwork = await databases.createDocument(appwriteConfig.databaseId, appwriteConfig.galleryCollectionId, ID.unique(), {
title: form.title,
year: form.year,
price: form.price,
edition: form.edition,
dimensions: form.dimensions,
images: image,
users: form.userId,
});
return newArtwork;
} catch (error) {
throw new Error("Failed Creating Artwork Error", error);
}
};```
I am using expo image picker. The permissions are all set properly and the configuration IDs are all set. It gives me a 404 error saying it cannot be accessed.
Any help is appreciated!
TL;DR
Developers are encountering a Network request failed error when trying to upload a picture to their storage in Appwrite. The code appears to be correct, but the issue persists. The error message indicates a 404 error for a file that cannot be accessed. This may be due to incorrect file paths or permissions. Double-check the file paths and permissions to resolve the issue. Recommended threads
- nextjs SSR session in CSR
Hi, How could you access the user session in a csr component I need access to the session for handling real time updates. As the cookie that contains the sessio...
- React Native Google OAuth Redirect
For 3 days I no longer understand why redirects with Google Auth on React Native do not work at all. I saw people asking the problem but the solutions do not wo...
- I want cancel all my plans
I didn't use the paid plan, only the free trial in October 2024. I forgot to update my current plan, and a payment attempt was made. Since I haven't used any re...
![](/images/bgs/pre-footer.png)