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 |
# 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(aws_config(config.transfer_config)) 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
19 20 21 22 23 24 25 26 27 |
# File 'lib/brillo/transferrer/s3.rb', line 19 def download return unless enabled logger.info("download #{path} from s3 #{bucket} #{filename}") FileUtils.rm path, force: true client.get_object({bucket: bucket, key: filename}, target: path) rescue Aws::S3::Errors::NoSuchBucket create_bucket retry end |
#upload ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/brillo/transferrer/s3.rb', line 29 def upload return unless enabled logger.info("uploading #{path} to s3 #{bucket} #{filename}") object = resource.bucket(bucket).object(filename) object.upload_file(path) rescue Aws::S3::Errors::NoSuchBucket create_bucket retry end |