Reputation: 199
I found there has no good example in aws-sdk document to list s3 objects with marker and max-keys options.
In Java, I can do it by :
ObjectListing objectListing = s3.listObjects(new ListObjectsRequest()
.withBucketName(bucket)
.withPrefix(s3Prefix)
.withMarker(s3Marker)
.withMaxKeys(40));
but in ruby, I can only find the with_prefix method but no way to fill other options. please help to tell how to config to list the objects with marker or max-kays
Upvotes: 3
Views: 1267
Reputation: 61
It took me a while to figure this out, for the same reasons: no good examples in the documents.
Here is how I managed to get it working, however:
items = bucket.objects.with_prefix(prefix).page(:next_token => { :marker => marker }, :per_page => 100)
items.each do |item|
puts item.key
end
items is a PageResult object.
I eventually figured out using a combination of the aws docs and reading the source code.
Upvotes: 4