Skip to content

blob prefixes only exist after iterating over blobs #192

@joostvham

Description

@joostvham

Environment details

  • Ubuntu 18.04
  • python 3.7.4
  • pip 19.0.3
  • google-cloud-storage version 1.29.0

Steps to reproduce

I have a bucket, with at the 'root' of the bucket 3 directories. I want to display these three directories. However, they only exist when iterating over the blobs first, without a clear reason.

Code example

from google.cloud import storage

bucket_name = 'bucket-name'
client = storage.Client()
bucket = client.get_bucket(bucket_name)
blobs = bucket.list_blobs(delimiter='/')

print('printing prefixes 1 ...')
print(blobs.prefixes)

[b for b in blobs]

print('printing prefixes 2 ...')
print(blobs.prefixes)

Output

python bucket.py 
printing prefixes 1 ...
set()
printing prefixes 2 ...
{'test-data/', 'unparsed-data/', 'raw-data/'}

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the googleapis/python-storage API.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