You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Function to list all files with pagination
def list_all_files(storage, bucket_name):
offset = 0
limit = 100 # The maximum number of files to retrieve per request
all_files = []
while True:
response = storage.from_(bucket_name).list(limit=limit, offset=offset)
files = response.data
if files:
all_files.extend(files)
offset += limit
else:
break
return all_files
# List all files in the bucket
all_files = list_all_files(supabase.storage, bucket_name)
print(f"Total files: {len(all_files)}")
I prefer to get a list of all file names in a bucket like
url: str = os.getenv("SUPABASE_URL")
#key: str = os.getenv("SUPABASE_SERVICE_ROLE_KEY")
key: str = os.getenv("SUPABASE_ANON_KEY")
supabase: Client = create_client(url, key)
SUPABASE_EMAIL = os.environ.get("SUPABASE_EMAIL")
SUPABASE_PASSWORD = os.environ.get("SUPABASE_PASSWORD")
# print secrets
print(SUPABASE_EMAIL, SUPABASE_PASSWORD)
my_session = supabase.auth.sign_in_with_password({"email": SUPABASE_EMAIL, "password":SUPABASE_PASSWORD})
#
# Your storage bucket name
bucket_name = "scratch-assignments"
#%%
# List files in the bucket
files = supabase.storage.from_("scratch-assignments").list()
#%%
print(len(files)) #prints 100 but there are 104 files in the storage
#%%
That's a list of dictionaries but the contents are not that large so I'm not sure why it's set to such a low limit. Can you parameterize it like
Rather than doing something like this:
I prefer to get a list of all file names in a bucket like
That's a list of dictionaries but the contents are not that large so I'm not sure why it's set to such a low limit. Can you parameterize it like
The text was updated successfully, but these errors were encountered: