I am using this sample code in nextjs
const storeFile = async () => { try { const uploader = document.getElementById( "uploader" ) as HTMLInputElement | null; if (!uploader) { throw new Error("Uploader element not found"); }
const file = uploader.files?.[0];
console.log(file);
if (!file) {
throw new Error("No file selected");
}
const promise = await storage.createFile(
process.env.BUCKET_ID as string,
ID.unique(),
file
);
return promise;
} catch (err) { alert(err); } };
You can try this : https://github.com/appwrite/appwrite/issues/2687
What are the permissions on the bucket?
Role ANY Permissions CREATE READ UPDATE
Would you please switch to the network tab, find the request, and share the request headers?
yes its working now some issue with env variables. My env variables were coming undefined
thats why cors was coming
[SOLVED] Getting CORS error while uploading files to bucket
Hello @Steven I'm having the same issues. Can you please share how I can fix this? I'm new to Appwrite and still don't understand how some of the services work.
I keep having the COR Policy issue each time I try to submit the file. Could it be the problem is from my env variables ?
Please create a new <#1072905050399191082> post
Recommended threads
- How to Display File in Web?
I'm trying to use Appwrite's Storage to store images and display them in my app, however when I use the `getFileView`, `getFileDownload` or `getFilePreview` met...
- Project Paused Despite Daily Active Usag...
I noticed that my project was automatically **paused**, even though it is actively being used. The project is an **attendance application** that is used daily b...
- Sudden CORS Errors - Domain hasn't Chang...
I have an Appwrite project with two web apps configured, the first one has the hostname `*` and the second one I just added to test if it could fix the issue wi...