Using Fog to examine S3 buckets
connection = Fog::Storage.new({
:provider => 'AWS',
:aws_access_key_id => 'my_key_id',
:aws_secret_access_key => 'secret_key',
:region => 'eu-west-1'
})
# get the bucket
s3_bucket_name = 'my_bucket'
dir = connection.directories.detect { | dir | dir.key == s3_bucket_name }
# iterate through files
dir.files.each { | file |
# do your work here
}
Written by Angus Mark
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#