Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not all files listed #39

Closed
dstreufert opened this issue Jan 24, 2024 · 5 comments
Closed

Not all files listed #39

dstreufert opened this issue Jan 24, 2024 · 5 comments

Comments

@dstreufert
Copy link

In the case where I have around 17,000 files in a directory, only the first 600-900 are shown in the directory listing.

Any ideas?

@Erisa
Copy link
Sponsor Collaborator

Erisa commented Jan 24, 2024

This is because R2 has a limit on how many objects can be listed in a single call to the API, which is 1,000 maximum but (If I recall correctly) can be lower based on the total byte size of the result. https://developers.cloudflare.com/r2/api/workers/workers-api-reference/#r2listoptions

Listing more than this using the Workers bindings requires a change to make multiple list calls, which can dramatically increase the latency and cost of the request, so would be tricky to implement in a sensible way.

@kotx
Copy link
Owner

kotx commented Jan 24, 2024

We could add a ...see more... link at the bottom of the page if there are more objects to be returned.
This would add a ?cursor=... to the url, which would then return all results after the cursor. You could then list all objects similarly to this method in cloudflare docs.

The question is if you need a configurable limit of objects per page (for example, so you can limit results to 50 per page), and/or an option for listing all files in a single request if the number of subrequests doesn't go over 50 on free, or 1k on paid.
Let me know what works for your needs, I can try to add it in the next few days.

@dstreufert
Copy link
Author

dstreufert commented Jan 24, 2024 via email

@dstreufert
Copy link
Author

dstreufert commented Jan 24, 2024 via email

@kotx
Copy link
Owner

kotx commented Jan 25, 2024

Just pushed a release (1.4.0) supporting pagination in page listings with ?cursor= as a query.

Even dirs with 255 subdirectories are only showing the first 10-15…

This may be a R2 API limitation. What I think is happening here is you have files in those subdirectories, reaching the listing limit of 1000 so there are only 10-15 unique /-delimited prefixes (=subdirectories).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants