Class: DZT::S3Storage
- Inherits:
-
Object
- Object
- DZT::S3Storage
- Defined in:
- lib/dzt/s3_storage.rb
Constant Summary collapse
- DEFAULT_ACL =
'public-read'
- DEFAULT_KEY =
''
Instance Method Summary collapse
-
#exists? ⇒ Boolean
Currently does not supporting checking S3 fo overwritten files.
-
#initialize(options = {}) ⇒ S3Storage
constructor
A new instance of S3Storage.
-
#mkdir(_path) ⇒ Object
no-op.
- #s3 ⇒ Object
- #storage_location(level) ⇒ Object
- #write(file, dest, options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ S3Storage
Returns a new instance of S3Storage.
12 13 14 15 16 17 18 |
# File 'lib/dzt/s3_storage.rb', line 12 def initialize( = {}) @s3_acl = [:s3_acl] || DEFAULT_ACL @s3_bucket = [:s3_bucket] @s3_key = [:s3_key] || DEFAULT_KEY @s3_id = [:aws_id] @s3_secret = [:aws_secret] end |
Instance Method Details
#exists? ⇒ Boolean
Currently does not supporting checking S3 fo overwritten files
32 33 34 |
# File 'lib/dzt/s3_storage.rb', line 32 def exists? false end |
#mkdir(_path) ⇒ Object
no-op
41 42 |
# File 'lib/dzt/s3_storage.rb', line 41 def mkdir(_path) end |
#s3 ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dzt/s3_storage.rb', line 20 def s3 @s3 ||= begin require_fog! Fog::Storage.new( provider: 'AWS', aws_access_key_id: @s3_id, aws_secret_access_key: @s3_secret ) end end |
#storage_location(level) ⇒ Object
36 37 38 |
# File 'lib/dzt/s3_storage.rb', line 36 def storage_location(level) "#{@s3_key}/#{level}" end |
#write(file, dest, options = {}) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/dzt/s3_storage.rb', line 44 def write(file, dest, = {}) quality = [:quality] s3.put_object(@s3_bucket, dest, file.to_blob { @quality = quality if quality }, 'Content-Type' => file.mime_type, 'x-amz-acl' => @s3_acl ) end |