Class: S3FileHandler::Folder::List
- Inherits:
-
BaseOperation
- Object
- BaseOperation
- S3FileHandler::Folder::List
- Defined in:
- lib/s3_file_handler/folder/list.rb
Instance Attribute Summary collapse
-
#bucket_name ⇒ Object
readonly
Returns the value of attribute bucket_name.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
Attributes inherited from BaseOperation
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(bucket_name, prefix_path: '', client: S3FileHandler.client) ⇒ List
constructor
A new instance of List.
Constructor Details
#initialize(bucket_name, prefix_path: '', client: S3FileHandler.client) ⇒ List
Returns a new instance of List.
8 9 10 11 12 13 |
# File 'lib/s3_file_handler/folder/list.rb', line 8 def initialize(bucket_name, prefix_path: '', client: S3FileHandler.client) super(client: client) @bucket_name = bucket_name @prefix = prefix_path.empty? || prefix_path.end_with?('/') ? prefix_path : "#{prefix_path}/" end |
Instance Attribute Details
#bucket_name ⇒ Object (readonly)
Returns the value of attribute bucket_name.
6 7 8 |
# File 'lib/s3_file_handler/folder/list.rb', line 6 def bucket_name @bucket_name end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
6 7 8 |
# File 'lib/s3_file_handler/folder/list.rb', line 6 def prefix @prefix end |
Instance Method Details
#execute ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/s3_file_handler/folder/list.rb', line 15 def execute handle_aws_errors do response = client.list_objects_v2( bucket: bucket_name, prefix: prefix, delimiter: '/' ) folders = response.common_prefixes.map(&:prefix) result({ folders: folders }) end end |