Search code examples
amazon-web-servicesamazon-s3pagination

Jumping Pagination for AWS S3 Bucket object


the pagination here is bit more flexible compared to other questions asked

Suppose I have 100 objects and on the UI I have a pagination component that shows 10 objects each page. enter image description here

To be able to jump to any page, currently in backend, I need to fetch all 100 objects and slice the needed range of array and return to UI. However, it results in extra cost of data tranfer and processing.

I thought of few ways, e.g. caching the whole list, but didnt figure out a way to efficiently let my backend be notified by new changes (can not get rid of possibilities of stale reads by just polling the API within some intervals).

Is there a way to just get a given index range of objects? is that possible solely relying on existing APIs?

I posted this question in aws-sdk-java repo on github, but unfortunately until now no response is given.


Solution

  • If you can use the V2 version of ListObjects, there is a parameter startAfter. You could try using startAfter to get the page you are looking for, without having to fetch the whole list. It doesn't solve all of your problems but it could help with the "fetch a given range" issue.