Hi guys! the supabase.getPublicUrl() method retur...
# help
d
Hi guys! the supabase.getPublicUrl() method returns a URL without ?token={token} at the end of the URL, so it can't be accessed as img src. How can i get the url+access token which the Copy URL button in my app.supabase/project/storage/buckets/bucket-name returns?
n
Hello @daviscup! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
g
https://supabase.com/docs/reference/dart/storage-from-createsignedurl This would require storage object policies for select on that bucket.
n
daviscup (2022-03-20)
d
Thanks for your answer. I updated the storage policies to Enable access to all users: SELECT ALL images are publicly accessible. Other policies under storage.objects SELECT Enable access to all users Policies under storage.buckets SELECT Enable access to all users The image seems to load the url correctly but still won't show (400 Bad Request) Am I doing something wrong here?
g
Is it a public bucket? If not you have to use createSignedUrl, you are showing a public url in your img. Also even for a public url your url is messed up. Is the name of your bucket "bucket"? And if so you put a / in front of the path.
d
Just realized there is another public slider when creating a bucket
it wasn't set to public and with createSignedUrl, it works perfectly
g
If it is set to public you don't need a signed URL
d
yeah I forgot that i set it to non-public when i created the bucket a week ago
g
Then just use the public URL not the signed one.
d
I guess for non-expiring URLS, i set the param to 0 ?
g
getPublicUrl() is what you normally use if anyone can access the file (public bucket) with the URL. No need to go to the database and get a token.
d
got it. so basically have one public bucket and get the urls with getPublicUrl() for public shop images and another restricted bucket for other specific private images
g
Yes. Public bucket only difference is there is a direct URL to storage that bypasses policies.
d
ok cool! thanks a lot. are you guys planning on offering different price packages between the free and pro tier?
g
I'm just a user helping out, no inside info.
d
oh, I see 😄
well then thanks for your time mate !