I am trying to list a large amount of gcs blobs using the Java API. Since the number of blobs is large, I tried to use pagination, but I am getting the same page repeatedly. The code looked like this:
Storage storage = StorageOptions.newBuilder().setCredentials(credentials).build().getService();
Page<Blob> allBlobs = storage.list(myBucketName,Storage.BlobListOption.pageSize(5000), Storage.BlobListOption.prefix("some prefix");
while (allBlobs.hasNextPage()) {
Page<Blob> page = allBlobs.getNextPage();
for (Blob blob : page.getValues()) {
.... do something....
}
}
It looks like I am getting the same page over and over. I looked at the token by allBlobs.getNextPageToken() and the token looked the same all the time. Did I miss something to move the page forward to the next one? Isn't getNextPage doing it? The Page interface has only a few methods defined. Did I overlook something?