How to list all files in an S3 folder using Fog in Ruby How to list all files in an S3 folder using Fog in Ruby ruby ruby

How to list all files in an S3 folder using Fog in Ruby


Use the prefix option on the directory.get method. Example:

def get_files(path, options)  connection = Fog::Storage.new(    provider: 'AWS',    aws_access_key_id: options[:key],    aws_secret_access_key: options[:secret]  )  connection.directories.get(options[:bucket], prefix: path).files.map do |file|    file.key  endend