-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There should be a built-in way to list prefixes (directories) in a bucket #294
Comments
Hi @lrowe, Would it help to document an example instead pydocs? Here's an example: |
@frankyn An example would be helpful too, but I think the Perhaps the
|
I do worry though that the current list_blobs Iterator.prefixes set might be problematic when there are a very large number of prefixes since it would grow unbounded. |
Thanks for clarifying @lrowe, how many prefixes are you expecting right now? We'd need to run tests to see how the library behaves. @HemangChothani could you update your PR to provide better documentation instead for now? |
I ran into this while building a Cloud Function storage trigger to generate directory listings in a bucket exposed as a static website containing output from programmatically generated analysis runs. Some of these 'directories' have ~50,000 subdirectories and I can imagine we may have cases in the future with an order of magnitude more and I will need to split the listing over multiple pages in order to keep it usable. |
Python documentation for list_blobs() needs to be updated to clarify that there's a property for python-storage/google/cloud/storage/client.py Lines 832 to 834 in fe87755
|
Hi, I believe there is an issue with the
But when I loop over the
It would be great to be have a built-in way to list prefixes directly without listing files, since it can be expensive in time and compute. Thank you in advance (and Merry Christmas 🎄) |
Improve documentation as part of 294 - clarify `prefixes` entity exists as part of the response - add link to sample broswer ["List the objects in a bucket using a prefix filter"](https://cloud.google.com/storage/docs/samples/storage-list-files-with-prefix#storage_list_files_with_prefix-python) Fixes #294 🦕
The REST API provides a way to list prefixes (directories) in a bucket but this does not seem to be supported by the client library.
According to #192 the iterator returned by
list_blobs
has aprefixes
field which is filled in as you iterate over the blob. This should be better documented, since it is only mentioned in passing:https://googleapis.dev/python/storage/latest/client.html#google.cloud.storage.client.Client.list_blobs
As well as a method to list prefixes alone, it would be helpful to have an iterator that returned both prefixes and objects in order for produce ordered listings.
Workaround found on Stack Overflow. https://stackoverflow.com/a/59008580
The text was updated successfully, but these errors were encountered: