Last active
August 21, 2018 18:23
-
-
Save rcgalbo/f801a890ead25d2ba4a993eb59c4af9e to your computer and use it in GitHub Desktop.
list the contents of a gcs bucket
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from google.cloud import storage | |
def list_blobs(bucket, prefix): | |
""" | |
Lists all the blobs in the bucket | |
make sure prefix ends with '/' | |
""" | |
storage_client = storage.Client() | |
bucket = storage_client.get_bucket(bucket) | |
blobs = bucket.list_blobs(prefix=prefix) | |
blob_list = [blob.name for blob in blobs] | |
return blob_list | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment