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