Skip to content
Back

[Closed] getFilePreview not working even with permission

  • 0
  • Resolved
  • 2
  • Self Hosted
  • Storage
Kompozition
5 Nov, 2025, 20:27

I am on Appwrite self hosted 1.8.0 I use the web sdk 21.3.0

I created a bucket and it has this permission (users:create) then i enabled the file security then i uploaded a file via the sdk and i passed the permission ( team: read, update, delete) and ( loggedInUser: read, update, delete)

When i use the SDK to get the image it fails, all 3 methods gives me 404, end the network tab shows (failed)net::ERR_BLOCKED_BY_ORB

When i set the entire bucket to fully public ( or all users can read ) then i get the image properly

If i get the link from Appwrite's dashboard i get the <,&mode=admin >> in the generated url then the file shows in the browser,

The link from the dashboard is same as the link from the sdk apart from the "mode"

I am not sure why this is not working here is the code i used

TypeScript
   return appwriteStorage.getFilePreview({
    bucketId:ServerStorageBucketIds.photos,
    fileId:photo.objectID,
   })
}
TL;DR
getFilePreview not working due to CORS issue when requesting from localhost to Appwrite hosted on a different domain. Options to solve: 1) Make a rest API call passing JWT token, 2) Add custom domain to Appwrite (not ideal for localhost), 3) Use Cloudflare worker to add JWT dynamically, or 4) Attach token after file upload (not recommended).
5 Nov, 2025, 21:03

anyone please???

5 Nov, 2025, 21:16

after looking here nad there I did find this issue https://github.com/appwrite/sdk-for-flutter/issues/7 it seems like it has fixed on flutter sdk back in 2021 but the issue still exist in the web sdk

5 Nov, 2025, 21:44

this is the permission on the file... I am still getting yhe issue

5 Nov, 2025, 22:06

getFilePreview not working even with permission

6 Nov, 2025, 00:37

looks like your request is getting blocked by CORS, its not a permission issue

6 Nov, 2025, 00:47

I investigated … turns out that I the cookies are not sent by chrome with the request (it explicitly says that it ignored it for the request 😓) … because I am doing the request from localhost and Appwrite is hosted on my domain.

From my research it seems like I can do either

  1. rest ApI call and pass the JWT token to it (will have to change my UI accordingly)
  2. add a custom domain to Appwrite so that the CORS get resolved ( I don’t want to do it for prod.. and it won’t help in localhost)
  3. use cloudflare worker to modify the request to Appwrite and dynamically add the jwt ( this one works better especially because workers executes close to the user location)
  4. attach a token after uploading a file (not a good idea) at the moment My application is Photo heavy (like Google photo) so doing this many cloud function call just to add a token to a file is not a good idea
6 Nov, 2025, 03:34

[Closed] getFilePreview not working even with permission

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more