I am working with a project which needs to use python to store the png file into supabase storage. But I do not know how to do that. Can anyone please help me?
I actually got a bucket in my storage. But when i use fllowing code to print buckets, it will just give me "[]".
url = storage_url
key = get_settings().supabase_key
headers = {"apiKey": key, "Authorization": f"Bearer {key}"}
storage_client = create_client(url, headers, is_async=False)
print(storage_client.list_buckets())
The method or the document for the question.
Supabase-py maintainer here. Thanks for the question! Supabase Storage makes use of Row Level Security(RLS) policies under the hood and will only show buckets that the client can view. If there are no buckets that a client can view it will return an empty list.
Could you check your Supabase Dashboard settings and ensure that you have a policy to allow for buckets for be read? At time of writing you'd do this by going to:
Supabase > Storage > Policies > Policies under Storage.buckets
Do ensure that you have a policy which allows for read access.
Here's an example for a read policy as taken from the Javascript library documentation. Do remember to change
public
to the name of your bucket.You can also configure the policy to restrict reads to authenticated users or users with other attributes. There's a list of example policy templates that you can reference - you should be able to see a tab with examples after clicking on create new policy.
Hope this helps and let me know if there are still issues.