Skip to content

Add support for ListObjectsV2 #741

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

Open
Ankk98 opened this issue May 14, 2025 · 7 comments
Open

Add support for ListObjectsV2 #741

Ankk98 opened this issue May 14, 2025 · 7 comments

Comments

@Ankk98
Copy link
Contributor

Ankk98 commented May 14, 2025

@geemus
Copy link
Member

geemus commented May 14, 2025

Similar here, we likely either overlooked it or it was added later. I'd certainly welcome a PR to add it if you have the time and inclination, and I'm certainly happy to support that however I can.

@Ankk98
Copy link
Contributor Author

Ankk98 commented May 16, 2025

Here is a quick idea on how ListObjectsV2 support can be added while maintaining V1 compatibility:

I will add:
A new request file: lib/fog/aws/requests/storage/list_objects_v2.rb
A new parser file: lib/fog/aws/parsers/storage/list_objects_v2.rb

Then we will be able to use it like:

storage.list_objects_v2('bucket-name', {
  'prefix' => 'my/prefix/',
  'max-keys' => 1000,
  'fetch-owner' => true
})

Optionally, we can add an option, use_v2 = true in:
Directories#get
Files#all
Directory#objects_keys
and other places where this is being used.

Is this fine?

@geemus
Copy link
Member

geemus commented May 19, 2025

@Ankk98 hmm, something along those lines sounds reasonable. Could you summarize the differences between v1 and v2, if you know them? I looked at the doc you linked, but it wasn't immediately obvious to me. Depending on how it has changed, it might make sense to make v2 the default for models, but I was having a hard time figuring out what was different.

@Ankk98
Copy link
Contributor Author

Ankk98 commented May 19, 2025

Key Differences

1. Pagination

  • ListObjects

    • Uses marker parameter for pagination
    • Returns NextMarker in response
    • More complex pagination logic
  • ListObjectsV2

    • Uses continuation-token parameter for pagination
    • Returns NextContinuationToken in response
    • Simpler and more efficient pagination mechanism

2. Response Structure

  • ListObjectsV2
    • Has additional fields like StartAfter and KeyCount

3. Performance

ListObjectsV2

  • Better performance
  • Optimized for large buckets
  • More efficient pagination

AWS recommends to use v2 API as default.

Ankk98 added a commit to Ankk98/fog-aws that referenced this issue May 19, 2025
@geemus
Copy link
Member

geemus commented May 27, 2025

Thanks for the updates, I think on reflection that your approach sounds like a good one.

I was debating whether we should instead have v2 be the new default for models and allow opting back into v1, but I worry that could inadvertently lead to breakage for people. So this is probably safer for now.

@Ankk98
Copy link
Contributor Author

Ankk98 commented May 27, 2025

Yeah, I think a 2 step approach will be good.
In the first PR we can add support for v2.
And later we can make v2 as default after some time in a different release.

If this sounds good to you, I can send a pr.

@geemus
Copy link
Member

geemus commented May 27, 2025

@Ankk98 Sure, sounds good to me, thanks!

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

2 participants