Class: Stashify::File::Google::Cloud::Storage
- Inherits:
-
Stashify::File
- Object
- Stashify::File
- Stashify::File::Google::Cloud::Storage
- Defined in:
- lib/stashify/file/google/cloud/storage.rb
Overview
An implementation for interacting with files in Google Cloud Storage buckets. The constructor needs an instance of Google::Cloud::Storage::Bucket in order to know which bucket to interact with.
Instance Method Summary collapse
- #contents ⇒ Object
- #delete ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(bucket:, path:) ⇒ Storage
constructor
A new instance of Storage.
- #write(contents) ⇒ Object
Constructor Details
#initialize(bucket:, path:) ⇒ Storage
Returns a new instance of Storage.
14 15 16 17 |
# File 'lib/stashify/file/google/cloud/storage.rb', line 14 def initialize(bucket:, path:) @bucket = bucket super(path: path) end |
Instance Method Details
#contents ⇒ Object
19 20 21 |
# File 'lib/stashify/file/google/cloud/storage.rb', line 19 def contents @bucket.file(path).download.string end |
#delete ⇒ Object
30 31 32 |
# File 'lib/stashify/file/google/cloud/storage.rb', line 30 def delete @bucket.file(path).delete end |
#exists? ⇒ Boolean
34 35 36 |
# File 'lib/stashify/file/google/cloud/storage.rb', line 34 def exists? @bucket.file(path) end |
#write(contents) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/stashify/file/google/cloud/storage.rb', line 23 def write(contents) @bucket.create_file( StringIO.new(contents), path, ) end |