client .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('647170480f75d7bd5b41') // Your project ID ;
methods: { handleFileUpload(event) { this.file = event.target.files[0]; }, async submitFile() { try { const response = await storage.createFile('64717d445b7a640fc647', ID.unique(), document.getElementById('file').files[0]); console.log(response); // Success } catch (error) { console.log(error); // Failure } }
}
import { Client, Storage, ID } from "appwrite";
Like this
Alright
Still having the same CORS error : Acess to XMLHttpRequest at 'https://cloud.appwrite.io/v1/storage/buckets/64717d445b7a640fc647/files' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
When i tried to upload
What else do you get in the console?
As localhost
should be enabled
These are what I'm seeing on my console
AppwriteException: Network request failed at Client.eval (webpack-internal:///./node_modules/appwrite/dist/esm/sdk.js:423:23) at Generator.throw (<anonymous>) at rejected (webpack-internal:///./node_modules/appwrite/dist/esm/sdk.js:42:65) browser-ponyfill.js:518 POST https://cloud.appwrite.io/v1/storage/buckets/64717d445b7a640fc647/files net::ERR_FAILED 404 eval @
So it's still 404
Can you check two things
- That this bucket is indeed inside this project and it has the necessary permissions.
- Share a screenshot of the preview tab inside the
network
tab
Yes.
Please can you explain what you meant in 2 ?
This is it, it's not showing any data
And the one after?
Same input
Everything looks allright. Can you share your bucket settings screen?
I ticked all
Is the URL is like this?
console/project-647170480f75d7bd5b41/storage/bucket-64717d445b7a640fc647/settings
With this IDs?
Yes it is
When I'm running this credentials it having problem finding the project ID
So the project ID is the issue ?
This the error i always get when i click to read the error:
{"message":"Storage bucket with the requested ID could not be found.","code":404,"type":"storage_bucket_not_found","version":"0.10.22"}
Hello @Binyamin i have solved it
[SOLVED] FIle Upload: CORS Error policy
Cool ππ
Recommended threads
- How to Avoid Double Requests in function...
I'm currently using Appwrite's `functions.createExecution` in my project. I want to avoid double requests when multiple actions (like searching or pagination) a...
- Send Email Verification With REST
I am using REST to create a user on the server side after receiving form data from the client. After the account is successfully created i wanted to send the v...
- Use different email hosts for different ...
Hello, I have 2 projects and i want to be able to set up email templates in the projects. Both projects will have different email host configurations. I see ...