cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re: Pagination in dropbox

Pagination in dropbox

Ashish_Bijlwan
Explorer | Level 4

Hi,

In dropbox, under an "image" folder we have 100 images and those images we are retrieving from the dropbox and showing in the app using dropbox API. The concern here is that it is taking a lot of time to display those images in the app because dropbox is providing all the images at once and I am unable to find any pagination concept with the dropbox API.

Is there any solution to load the images in a group of 5  i.e we will get the first 5 images then the next 5 images and so on...

 

 

Thanks and Regards

Ashish

5 Replies 5

Greg-DB
Dropbox Staff

Can you clarify what you mean when you say "dropbox is providing all the images at once"? For instance, what method(s) are you using?

 

For example, to list the contents of a folder, you would use the /2/files/list_folder and /2/files/list_folder/continue endpoints, which are paginated by design. You can also set an approximate maximum number of entries to return per page by setting the 'limit' parameter when calling /2/files/list_folder. Check out the linked documentation for more information on that.

 

Or, when using endpoints to retrieve the actual data of specific files, such as /2/files/download or /2/files/get_thumbnail_v2, the app controls how many calls to make and when, so that's under your control.

 

By the way, those are links to the documentation for the HTTPS endpoints themselves, but we recommend using one of the official SDKs if possible. Those have corresponding native methods for the HTTPS endpoints. If you are using one of those, refer to the relevant SDK documentation for the corresponding documentation for the above HTTPS endpoints.

Ashish_Bijlwan
Explorer | Level 4

Thanks for your replay @Greg-DB .......

I am using the dropbox Java SDK  and in that, I am using listFolder(String Path) method to get the list of images(files). Can we get the files as a paginated way means first 5 files then next 5 and so on...

 

 

Thanks and Regards

Ashish

Greg-DB
Dropbox Staff

Yes, in the Dropbox API v2 Java SDK, the corresponding methods are listFolder, listFolderBuilder, and listFolderContinue.

 

You can use listFolderBuilder to get a ListFolderBuilder so you can use ListFolderBuilder.withLimit to set the desired approximate page size limit, and then page through using ListFolderBuilder.start and listFolderContinue.

Ashish_Bijlwan
Explorer | Level 4

Hi @Greg-DB 
Whenever i am using the ListFolderBuilder.start and listFolderContinue methods from javasdk to get the content as a pagination then I am not getting the content as sequentially.
Ex : In Dropbox , Inside the "Image" folder, I have uploaded 10 images. Whenever I am retrieving those image from Dropbox using ListFolderBuilder.start and listFolderContinue methods with the limit of 4 then sometimes Initially I am getting the image5,image6,image7,image8 then image1,image2,image3,image4 then image9,image10. Its not in the sequence like its there in the Dropbox.

The sequence/order of the uploaded images are in the Dropbox :
image1.png
image2.png
image3.png
..........
..........
image10.png

is there anything I am missing in my code?

 

Thanks and Regards

Ashish

Greg-DB
Dropbox Staff

The listFolder functionality does not guarantee a particular ordering or offer options for controlling the order of the returned entries. You should retrieve all of the entries and then apply whatever sorting you want client-side.

Need more support?