Spaces:
Sleeping
Sleeping
Update get_supabase.py
Browse files- get_supabase.py +19 -8
get_supabase.py
CHANGED
|
@@ -1,16 +1,27 @@
|
|
| 1 |
-
import os
|
| 2 |
-
from supabase import create_client,
|
| 3 |
-
from
|
| 4 |
|
| 5 |
-
class Supabase:
|
| 6 |
def __init__(self):
|
| 7 |
pass
|
| 8 |
|
| 9 |
-
def init_supabase_client(self):
|
| 10 |
load_dotenv()
|
| 11 |
try:
|
| 12 |
-
client
|
|
|
|
| 13 |
return client
|
| 14 |
-
except
|
| 15 |
print(f"Error initializing Supabase client: {e}")
|
| 16 |
-
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from supabase import create_client,Client
|
| 3 |
+
from dotenv import load_dotenv
|
| 4 |
|
| 5 |
+
class Supabase :
|
| 6 |
def __init__(self):
|
| 7 |
pass
|
| 8 |
|
| 9 |
+
def init_supabase_client(self):
|
| 10 |
load_dotenv()
|
| 11 |
try:
|
| 12 |
+
client :Client = create_client(os.getenv("SUPABASE_URL"),os.getenv("SUPABASE_KEY"))
|
| 13 |
+
|
| 14 |
return client
|
| 15 |
+
except Exception as e :
|
| 16 |
print(f"Error initializing Supabase client: {e}")
|
| 17 |
+
return None
|
| 18 |
+
|
| 19 |
+
def download_bucket_storage(self,bucket_name):
|
| 20 |
+
client = self.init_supabase_client()
|
| 21 |
+
files_list = client.storage.from_(bucket_name).list()
|
| 22 |
+
for file in files_list :
|
| 23 |
+
client.storage.from_(bucket_name).download(file)
|
| 24 |
+
|
| 25 |
+
L = Supabase()
|
| 26 |
+
print(L.init_supabase_client())
|
| 27 |
+
L.download_bucket_storage("CVs")
|