Class: Brillo::Transferrer::S3
- Inherits:
-
Object
- Object
- Brillo::Transferrer::S3
- Includes:
- Helpers::ExecHelper, Logger
- Defined in:
- lib/brillo/transferrer/s3.rb
Instance Attribute Summary collapse
-
#bucket ⇒ Object
readonly
Returns the value of attribute bucket.
-
#enabled ⇒ Object
readonly
Returns the value of attribute enabled.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
Instance Method Summary collapse
- #download ⇒ Object
-
#initialize(config) ⇒ S3
constructor
A new instance of S3.
- #upload ⇒ Object
Methods included from Logger
Methods included from Helpers::ExecHelper
Constructor Details
#initialize(config) ⇒ S3
Returns a new instance of S3.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/brillo/transferrer/s3.rb', line 10 def initialize(config) @enabled = config.transfer_config.enabled @bucket = config.transfer_config.bucket @region = config.transfer_config.region @filename = config.compressed_filename @path = config.compressed_dump_path Aws.config.update( credentials: Aws::Credentials.new( config.transfer_config.access_key_id, config.transfer_config.secret_access_key ), region: config.transfer_config.region ) end |
Instance Attribute Details
#bucket ⇒ Object (readonly)
Returns the value of attribute bucket.
8 9 10 |
# File 'lib/brillo/transferrer/s3.rb', line 8 def bucket @bucket end |
#enabled ⇒ Object (readonly)
Returns the value of attribute enabled.
8 9 10 |
# File 'lib/brillo/transferrer/s3.rb', line 8 def enabled @enabled end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
8 9 10 |
# File 'lib/brillo/transferrer/s3.rb', line 8 def filename @filename end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/brillo/transferrer/s3.rb', line 8 def path @path end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
8 9 10 |
# File 'lib/brillo/transferrer/s3.rb', line 8 def region @region end |
Instance Method Details
#download ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/brillo/transferrer/s3.rb', line 25 def download return unless enabled FileUtils.rm path, force: true client.get_object({bucket: bucket, key: path.to_s}, target: path) rescue Aws::S3::Errors::NoSuchBucket create_bucket retry end |
#upload ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/brillo/transferrer/s3.rb', line 34 def upload return unless enabled object = resource.bucket(bucket).object(path.to_s) object.upload_file(path) rescue Aws::S3::Errors::NoSuchBucket create_bucket retry end |