Class: EchoUploads::S3Store
- Inherits:
-
AbstractStore
- Object
- AbstractStore
- EchoUploads::S3Store
- Defined in:
- lib/echo_uploads/s3_store.rb
Instance Method Summary collapse
- #delete(key) ⇒ Object
- #exists?(key) ⇒ Boolean
- #read(key) ⇒ Object
- #url(key, options = {}) ⇒ Object
- #write(key, file, metadata) ⇒ Object
Instance Method Details
#delete(key) ⇒ Object
6 7 8 |
# File 'lib/echo_uploads/s3_store.rb', line 6 def delete(key) bucket.object(path(key)).delete end |
#exists?(key) ⇒ Boolean
10 11 12 |
# File 'lib/echo_uploads/s3_store.rb', line 10 def exists?(key) bucket.object(path(key)).exists? end |
#read(key) ⇒ Object
14 15 16 |
# File 'lib/echo_uploads/s3_store.rb', line 14 def read(key) bucket.object(path(key)).get.body.read end |
#url(key, options = {}) ⇒ Object
18 19 20 21 |
# File 'lib/echo_uploads/s3_store.rb', line 18 def url(key, = {}) = {method: :get}.merge() bucket.object(path(key)).presigned_url .delete(:method), end |
#write(key, file, metadata) ⇒ Object
23 24 25 26 |
# File 'lib/echo_uploads/s3_store.rb', line 23 def write(key, file, ) file.rewind bucket.object(path(key)).put body: file, content_type: .mime_type end |