Class: S3Cat::FileLister
- Inherits:
-
Object
- Object
- S3Cat::FileLister
- Defined in:
- lib/s3_cat/file_lister.rb
Instance Method Summary collapse
-
#initialize(s3_client: S3Cat.s3_client) ⇒ FileLister
constructor
A new instance of FileLister.
- #list_files(bucket, prefix) ⇒ Object
Constructor Details
#initialize(s3_client: S3Cat.s3_client) ⇒ FileLister
Returns a new instance of FileLister.
5 6 7 |
# File 'lib/s3_cat/file_lister.rb', line 5 def initialize(s3_client: S3Cat.s3_client) @s3_client = s3_client end |
Instance Method Details
#list_files(bucket, prefix) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/s3_cat/file_lister.rb', line 9 def list_files(bucket, prefix) Enumerator.new do |y| continuation_token = nil loop do response = s3_client.list_objects_v2(bucket: bucket, prefix: prefix, continuation_token: continuation_token) response.contents.map(&:key).each { |key| y << key } break unless response.is_truncated continuation_token = response.continuation_token end end end |