Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
List/fetch all objects in a bucket with AWS::S3 Ruby gem
# by default you only get 1000 objects at a time
# so you have to roll your own cursor
objects = []
last_key = nil
new_objects = AWS::S3::Bucket.objects(bucket_name, :marker => last_key)
objects += new_objects
last_key = objects.last.key
end while new_objects.size > 0
# you can easily define the above as an all_objects method on AWS::S3::Bucket

This comment has been minimized.

Copy link

@raven-chen raven-chen commented Jun 6, 2013

thank you ! I didn't realized amazon won't return all s3 file at one time.. almost wasted 2 hours..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.