getFileView() returns 401 Unauthorized even when user is authenticated and has read permission
- 1
- Self Hosted
- Web
- Storage
- Cloud

Description:
I’m encountering a 401 Unauthorized error when attempting to access a file URL returned by storage.getFileView(...), even though the user is authenticated and has been granted the appropriate read permission on the file.
Steps to Reproduce: 1. A logged-in user uploads a file to a bucket using Appwrite’s Storage API. 2. The collection is assigned read permissions to a specific user (read("user:USER_ID")) or team (read("team:TEAM_ID")) (file level security is disabled). 3. I retrieve the file view URL using:
const url = await storage.getFileView(bucketId, fileId);
4. I try to open this URL (e.g., in a new browser tab).
5. I get the following response from the server:
{ "message": "The current user is not authorized to perform the requested action.", "code": 401, "type": "user_unauthorized" }
What I Expected:
I expected the returned getFileView URL to load the file as the authenticated user has read permission and is logged in.
What Actually Happened:
The URL returns a 401 Unauthorized unless I either: • Set the permission to read("any"), or • Append &mode=admin (which works only in the same session with an active session cookie I get 401 on incognito mode).
Environment: • Appwrite Version: 1.6.1 • SDK: Web SDK (Vue 3 + Nuxt) • Deployment: Self-hosted (Docker) • Auth: Email/password login with session By the way, I can delete the file without problem.
