Fog を使用して特定の S3 "ディレクトリ" 内のすべてのファイルを一覧表示するにはどうすればよいですか?
S3 がファイルをフォルダーに保存しないことは知っていますが、バケット内のリスト全体を取得するのではなく、返されるファイルを特定の「フォルダー」に制限する方法が必要です。
prefix
directory.get メソッドでオプションを使用します。例:
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
end
end