Skip to content

Blob prefixes not available until you iterate the files #863

@eavonius

Description

@eavonius

Environment details

  • OS type and version: Windows 10
  • Python version: 3.9.13
  • pip version: 22.0.4
  • google-cloud-storage version: 2.5.0

Steps to reproduce

  1. Download the sample code for listing files with a prefix.
  2. Comment out the lines 56-58 that print the names of each blob.
  3. Create a google cloud storage bucket with a subfolder, and a file within that subfolder.
  4. Run the sample where it specifies the subfolder as the prefix with slash at the end (as shown) and the delimiter of '/'.
  5. Nothing is displayed (the prefixes are empty).
  6. Un-comment the lines that print the names of each blob.
  7. Run it again.
  8. The prefixes are displayed.

It appears you cannot list the prefixes unless you iterate the files first. This seems strange.

If it's intended, maybe this library should pre-iterate the list so this doesn't happen? Or at least document that this is expected?

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the googleapis/python-storage API.samplesIssues that are directly related to samples.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions