You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
setMaxResults doesn't seem to work for Cloud Storage API #1511
Looks like it is by design. Though I agree, the API signature, naming and documentation are confusing.
Apparently Storage.setMaxResults() sets the maximum size for the results page, and the maximum allowed value for it is 1000 (not properly documented).
As a workaround the following code can be used (it will successfully read > 1000 objects, page by page):
publicclassMyStorageExample {
publicstaticvoidmain(String[] args) throwsGeneralSecurityException, IOException {
Storage.Buildersb = newBuilder(
GoogleNetHttpTransport.newTrustedTransport(),
newJacksonFactory(),
null);
Storagestorage = sb.build();
Objectsobjects;
StringpageToken = null;
finallongmaxPageSize = 1000L; // 1000 is the maximum possible valuefinalStringbucketName = "<YOUR_BUCKET_NAME>";
do {
objects = storage
.objects()
.list(bucketName)
.setMaxResults(maxPageSize)
.setPageToken(pageToken)
.execute();
pageToken = objects.getNextPageToken();
if(objects.getItems() != null) {
System.out.println(objects.getItems().size());
}
} while (pageToken != null);
}
}
@vam-google I'm using something similar to what you're describing. I think it would be nice to improve the docs a bit to make it clear that 1000 is the maximum value.
The documentation and default value was updated for the Storage API, and will be available in the never version, once it is released. Closing the issue.
Activity
garrettjonesgoogle commentedon Jan 11, 2017
Could you try using a more recent version? The artifact is now named
and the latest version isgoogle-cloud-java0.8.1.johanhaleby commentedon Jan 11, 2017
Oh I was unaware of the change of artifactId, thanks for the hint. I'll try to look into it in a few days if that's ok.
johanhaleby commentedon Jan 13, 2017
Is
google-cloud-javain maven central? I can't seem to find it.garrettjonesgoogle commentedon Jan 13, 2017
Oops sorry, the artifact is named
google-cloud.garrettjonesgoogle commentedon Jan 26, 2017
@johanhaleby , were you able to try out the new version?
vam-google commentedon Jan 31, 2017
Looks like it is by design. Though I agree, the API signature, naming and documentation are confusing.
Apparently Storage.setMaxResults() sets the maximum size for the results page, and the maximum allowed value for it is 1000 (not properly documented).
As a workaround the following code can be used (it will successfully read > 1000 objects, page by page):
johanhaleby commentedon Feb 2, 2017
@vam-google I'm using something similar to what you're describing. I think it would be nice to improve the docs a bit to make it clear that 1000 is the maximum value.
Thanks for the support everyone.
vam-google commentedon Feb 9, 2017
The documentation and default value was updated for the Storage API, and will be available in the never version, once it is released. Closing the issue.
18 remaining items
chore(main): release 2.5.2 (#774)
chore(main): release 2.3.15 (#1519)
fix(deps): Update the Java code generator (gapic-generator-java) to 2…
chore(main): release 3.15.16 (#1515)
chore(main): release 0.132.15-alpha-SNAPSHOT (#1511)
chore: disable the Owl Bot post-processor (#1511)
chore(deps): update dependency com.google.cloud:google-cloud-shared-c…
fix(deps): Update the Java code generator (gapic-generator-java) to 2…
chore(main): release 3.15.16 (googleapis#1515)
chore(deps): update dependency com.google.cloud:google-cloud-shared-c…
chore(main): release 0.132.15-alpha-SNAPSHOT (#1511)
chore(deps): update dependency com.google.cloud:libraries-bom to v26.…
chore(deps): update dependency com.google.cloud:libraries-bom to v26.…
chore(deps): update dependency com.google.cloud:libraries-bom to v26.…
chore: use gcp-docuploader 0.6.3 (googleapis#1708) (googleapis#1511)