1

I'm trying to have the list of files into a bucket on Google Cloud Storage, unfortunately my script return always a void list, while there are some file into the bucket.

bucket_name = 'myBucket'
stats = cloudstorage.listbucket(
    bucket_name + '/myfolder', 
    max_keys = page_size, 
    prefix = ''
)

print(stats)
for stat in stats:
    print(stat)
Vito Lipari
  • 795
  • 8
  • 35

1 Answers1

0

I found a soluction

client = None
if path_to_json is None:
    client = storage.Client()
client = storage.Client.from_service_account_json(path_to_json)

bucket = client.get_bucket(bucket_name)
file_list = [blob.name for blob in bucket.list_blobs()]
Vito Lipari
  • 795
  • 8
  • 35