© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3y ago•
41 replies
Daniel

How to use token in URL for Supabase Storage?

Hello!
I have a private bucket named
profile-pictures
profile-pictures

Inside this bucket are folders with the
auth.uid()
auth.uid()
of the user
Inside each folder are images.

I want the SELECT access for images to be either if the user is authenticated, OR the
auth.uid()
auth.uid()
of the folder matches a row in a table named
public_profile
public_profile


I have this RLS set up on my
profile-pictures
profile-pictures
storage bucket.

2 RLS Policies:
First:
Target roles:
authenticated
authenticated

Using:
(bucket_id = 'profile-pictures'::text)
(bucket_id = 'profile-pictures'::text)


This would mean that if you're authenticated, you can view everything inside
profile-pictures
profile-pictures


Second:
Target Roles:
anon
anon

Using:
((bucket_id = 'profile-pictures'::text) AND ( SELECT (EXISTS ( SELECT 1
           FROM user_public_profile upp
          WHERE ((upp.user_id)::text = (storage.foldername(objects.name))[1]))) AS "exists"))
((bucket_id = 'profile-pictures'::text) AND ( SELECT (EXISTS ( SELECT 1
           FROM user_public_profile upp
          WHERE ((upp.user_id)::text = (storage.foldername(objects.name))[1]))) AS "exists"))


There are 2 issues:
Inside of
user_public_profile
user_public_profile
I have a row where
user_id
user_id
is
daecbccc-5689-4d06-8020-e2dbf722456f
daecbccc-5689-4d06-8020-e2dbf722456f


But when calling
https://tsr.supabase.co/storage/v1/object/profile-pictures/daecbccc-5689-4d06-8020-e2dbf722456f/0.jpg
https://tsr.supabase.co/storage/v1/object/profile-pictures/daecbccc-5689-4d06-8020-e2dbf722456f/0.jpg


with the Anon Bearer token, I'm getting object_not_found.

The other question is, is it possible to have all this inside the URL instead of headers, similar to how the signedURL works?
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Supabase S3 Storage - StorageUnknownError code: -32603
SupabaseSSupabase / help-and-questions
2y ago
Storage in Supabase
SupabaseSSupabase / help-and-questions
13mo ago
Supabase CLI & Gitpod - How to change Supabase URL for Supabase Studio
SupabaseSSupabase / help-and-questions
4y ago
Exchanging provider token for Supabase token
SupabaseSSupabase / help-and-questions
4y ago