Class: Stashify::File::AWS::S3
- Inherits:
-
Stashify::File
- Object
- Stashify::File
- Stashify::File::AWS::S3
- Defined in:
- lib/stashify/file/aws/s3.rb
Overview
An implementation for interacting with files in AWS S3 buckets. The constructor needs an instance of Aws::S3::Bucket order to know which bucket to interact with.
Instance Method Summary collapse
- #contents ⇒ Object
- #delete ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(bucket:, path:) ⇒ S3
constructor
A new instance of S3.
- #write(contents) ⇒ Object
Constructor Details
#initialize(bucket:, path:) ⇒ S3
Returns a new instance of S3.
12 13 14 15 |
# File 'lib/stashify/file/aws/s3.rb', line 12 def initialize(bucket:, path:) @bucket = bucket super(path: path) end |
Instance Method Details
#contents ⇒ Object
17 18 19 |
# File 'lib/stashify/file/aws/s3.rb', line 17 def contents @bucket.object(path).get.body.read end |
#delete ⇒ Object
25 26 27 |
# File 'lib/stashify/file/aws/s3.rb', line 25 def delete @bucket.object(path).delete end |
#exists? ⇒ Boolean
29 30 31 |
# File 'lib/stashify/file/aws/s3.rb', line 29 def exists? @bucket.object(path).exists? end |
#write(contents) ⇒ Object
21 22 23 |
# File 'lib/stashify/file/aws/s3.rb', line 21 def write(contents) @bucket.object(path).put(body: contents) end |