GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — setMaxResults doesn't seem to work for Cloud Storage API · Issue #1511 · googleapis/google-cloud-java

setMaxResults doesn't seem to work for Cloud Storage API #1511

New issue
Copy link
New issue
Copy link
Closed
Closed
setMaxResults doesn't seem to work for Cloud Storage API#1511
Copy link
Assignees
vam-google
Labels
api: storageIssues related to the Cloud Storage API.

Description

@johanhaleby
johanhaleby
opened on Jan 6, 2017
Issue body actions

I'm using:

<dependency>
            <groupId>com.google.cloud</groupId>
            <artifactId>gcloud-java</artifactId>
            <version>0.2.8</version>
</dependency>

which transitively depends on com.google.apis:google-api-services-storage:v1-rev62-1.21.0 and I have the following code:

Storage storage = ...
storage.objects().list(bucket).setMaxResults((long) Integer.MAX_VALUE).execute().getItems();

However the number of items are still 1000 (which is the default value) regardless of the value I pass to setMaxResults:

System.out.println(storage.objects().list(bucket).setMaxResults((long) Integer.MAX_VALUE).execute().size());

This yields 1000 as result.

Reacted by Les Vogel

Activity

Next
  1. garrettjonesgoogle commented on Jan 11, 2017

    @garrettjonesgoogle
    garrettjonesgoogle
    on Jan 11, 2017
    Contributor
    More actions

    Could you try using a more recent version? The artifact is now named google-cloud-java and the latest version is 0.8.1.

  2. garrettjonesgoogle
    added
    api: storageIssues related to the Cloud Storage API.
    on Jan 11, 2017
  3. johanhaleby commented on Jan 11, 2017

    @johanhaleby
    johanhaleby
    on Jan 11, 2017
    Author
    More actions

    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.

  4. johanhaleby commented on Jan 13, 2017

    @johanhaleby
    johanhaleby
    on Jan 13, 2017
    Author
    More actions

    Is google-cloud-java in maven central? I can't seem to find it.

  5. garrettjonesgoogle commented on Jan 13, 2017

    @garrettjonesgoogle
    garrettjonesgoogle
    on Jan 13, 2017
    Contributor
    More actions

    Oops sorry, the artifact is named google-cloud.

  6. garrettjonesgoogle commented on Jan 26, 2017

    @garrettjonesgoogle
    garrettjonesgoogle
    on Jan 26, 2017
    Contributor
    More actions

    @johanhaleby , were you able to try out the new version?

  7. garrettjonesgoogle
    added
    blocking GA
    on Jan 27, 2017
  8. vam-google
    self-assigned this
    on Jan 27, 2017
  9. vam-google commented on Jan 31, 2017

    @vam-google
    vam-google
    on Jan 31, 2017
    Contributor
    More actions

    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):

    public class MyStorageExample {
    
      public static void main(String[] args) throws GeneralSecurityException, IOException {
        Storage.Builder sb = new Builder(
            GoogleNetHttpTransport.newTrustedTransport(),
            new JacksonFactory(),
            null);
        Storage storage = sb.build();
    
        Objects objects;
        String pageToken = null;
        final long maxPageSize = 1000L; // 1000 is the maximum possible value
        final String bucketName = "<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);
      }
    }
  10. johanhaleby commented on Feb 2, 2017

    @johanhaleby
    johanhaleby
    on Feb 2, 2017
    Author
    More actions

    @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.

  11. vam-google commented on Feb 9, 2017

    @vam-google
    vam-google
    on Feb 9, 2017
    Contributor
    More actions

    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.

  12. vam-google
    closed this as completedon Feb 9, 2017
  13. garrettjonesgoogle
    added
    Status: Release Blocking
    and removed
    blocking GA
    on Mar 10, 2017
  14. theacodes
    unassigned
    vam-google
    on Sep 28, 2018
  15. 18 remaining items

  16. github-actions
    added a commit that references this issue on Sep 16, 2022

    chore(main): release 2.5.2 (#774)

    0b594e6
  17. github-actions
    added a commit that references this issue on Oct 4, 2022

    chore(main): release 2.3.15 (#1519)

    a87b8fc
  18. meltsufin
    added 2 commits that reference this issue on Dec 22, 2025

    fix(deps): Update the Java code generator (gapic-generator-java) to 2…

    e2f574c

    chore(main): release 3.15.16 (#1515)

    f14acdd
  19. chingor13
    added a commit that references this issue on Jan 6, 2026

    chore(main): release 0.132.15-alpha-SNAPSHOT (#1511)

    88973c6
  20. chingor13
    added a commit that references this issue on Jan 22, 2026

    chore: disable the Owl Bot post-processor (#1511)

    d9dff92
  21. chingor13
    added a commit that references this issue on Feb 24, 2026

    chore(deps): update dependency com.google.cloud:google-cloud-shared-c…

    ea0dca6
  22. suztomo
    added 2 commits that reference this issue on Mar 11, 2026

    fix(deps): Update the Java code generator (gapic-generator-java) to 2…

    078d2ff

    chore(main): release 3.15.16 (googleapis#1515)

    7255dba
  23. chingor13
    added a commit that references this issue on Mar 12, 2026

    chore(deps): update dependency com.google.cloud:google-cloud-shared-c…

    d835a44
  24. lqiu96
    added a commit that references this issue on Mar 20, 2026

    chore(main): release 0.132.15-alpha-SNAPSHOT (#1511)

    37ca395
  25. suztomo
    added a commit that references this issue on Mar 23, 2026

    chore(deps): update dependency com.google.cloud:libraries-bom to v26.…

    ad5f941
  26. suztomo
    added a commit that references this issue on Mar 30, 2026

    chore(deps): update dependency com.google.cloud:libraries-bom to v26.…

    9f2b9f6
  27. lqiu96
    added a commit that references this issue on Apr 1, 2026

    chore(deps): update dependency com.google.cloud:libraries-bom to v26.…

    dd9aa4a
  28. benjaminp
    added a commit that references this issue on Jul 13, 2026

    chore: use gcp-docuploader 0.6.3 (googleapis#1708) (googleapis#1511)

    fce94f0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @vam-google
    vam-google

Labels

api: storageIssues related to the Cloud Storage API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.