Class: NxtHerokuDatabaseBackup::Uploader::S3
- Inherits:
-
Object
- Object
- NxtHerokuDatabaseBackup::Uploader::S3
- Includes:
- NxtInit
- Defined in:
- lib/nxt_heroku_database_backup/uploader/s3.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.build(bucket_name:, file_path:, backup_name:, credentials: default_credentials) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/nxt_heroku_database_backup/uploader/s3.rb', line 7 def build(bucket_name:, file_path:, backup_name:, credentials: default_credentials) new( bucket_name: bucket_name, file_path: file_path, backup_name: backup_name, credentials: credentials ) end |
Instance Method Details
#aws_object ⇒ Object
33 34 35 36 37 38 |
# File 'lib/nxt_heroku_database_backup/uploader/s3.rb', line 33 def aws_object @aws_object ||= begin ensure_bucket_exists Aws::S3::Resource.new(credentials).bucket(bucket_name).object(backup_name) end end |
#call ⇒ Object
29 30 31 |
# File 'lib/nxt_heroku_database_backup/uploader/s3.rb', line 29 def call aws_object.upload_file(file_path) end |
#client ⇒ Object
46 47 48 |
# File 'lib/nxt_heroku_database_backup/uploader/s3.rb', line 46 def client @client ||= Aws::S3::Client.new(**credentials) end |
#ensure_bucket_exists ⇒ Object
40 41 42 43 44 |
# File 'lib/nxt_heroku_database_backup/uploader/s3.rb', line 40 def ensure_bucket_exists client.head_bucket(bucket: bucket_name) rescue Aws::S3::Errors::NotFound client.create_bucket(bucket: bucket_name) end |