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
}