Forum Discussion

Anil's avatar
Anil
Explorer | Level 4
9 years ago

Search all files using searchbuilder

I am trying to list all files in the folder using searchBuilder, when I passing the multiple extensions passing in Query which results Zero values. 

For Eg:

String query = ".pdf";
Long max = 100L;
Long stat = 0L;

SearchResult sresult;
SearchMode mode = SearchMode.FILENAME;
sresult = DropboxClient.getClient().files().searchBuilder(path, query).withMode(mode).withMaxResults(max).withStart(stat).start();
java.util.List<SearchMatch> res = sresult.getMatches();

Above code works fine for me, But i trying to multiple extensions ".pdf .jpg" it will not works.

Is any possible way to search all files with any maxmium limit?

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    The search functionality doesn't support searching for files with one or more of the search terms. It works by searching for all of them. We'll consider this a feature request.

     

    Instead, you should either make multiple search calls, one per file type, or use listFolder and listFolderContinue to list all files in a given folder, and filter them as desired.

    • Anil's avatar
      Anil
      Explorer | Level 4

      Thanks Greg for the QuickReply. Currently i am using ListFolder and it will take some if the folder has 10000 files or more. What i am trying to do is to load limited files for better UI experiences for eg: 100 and another set of 100 files only when user demands.  Is any options for listing files with limit in ListFolder API?

      • Greg-DB's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff
        No, ListFolder doesn't allow you to configure the page size, but I'll be sure to pass this along as a feature request as well.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,950 PostsLatest Activity: 29 minutes ago
352 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!