Amazon S3 and ruby with fog

This little script lists all keys of directories (buckets in S3) and files (objects). Just to get a grip with fog (https://github.com/geemus/fog)…

connection = Fog::Storage.new(
  :provider                 => 'AWS',
  :aws_secret_access_key    => "",
  :aws_access_key_id        => ""
)

dirs = connection.directories
dirs.each do |dir|
  puts "+ " + dirname = dir.key
  files = dirs.get(dirname).files
  files.each do |file|
    puts "  - " + file.key
  end
end