Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Provide Storage.BlobListOption.defaultInstance() method for idiomatically listing every item in a GCS bucket #2667

Copy link
Copy link

Description

@joaoandremartins
Issue body actions

I want to list every object in a bucket and add it to a list.

I want to use code similar to this:

		Storage.BlobListOption blobListOption = null;

		do {
			page = this.gcs.list(path, blobListOption);
			for (BlobInfo blob : page.getValues()) {
				blobs.add(blob);
			}
			blobListOption = Storage.BlobListOption.pageToken(page.getNextPageToken());
		} while (page.hasNextPage());

This code blows up with an NPE as expected. In order to make it work, I either need to duplicate the logic inside the while loop to get the first page with a this.gcs.list(path) call, or add a bogus Storage.BlobListOption, like Storage.BlobListOption.pageSize(50) instead of null at the beginning.

To support cases like this, there should be a Storage.BlobListOption factory for an empty Storage.BlobListOption.

Unless I'm missing anything?

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.