Class: ActiveRecord::Snapshot::S3
- Inherits:
-
Object
- Object
- ActiveRecord::Snapshot::S3
- Defined in:
- lib/active_record/snapshot/commands/s3.rb
Instance Method Summary collapse
- #download_to(path) ⇒ Object
-
#initialize(directory:) ⇒ S3
constructor
A new instance of S3.
- #read(path) ⇒ Object
- #upload(path) ⇒ Object
Constructor Details
#initialize(directory:) ⇒ S3
Returns a new instance of S3.
6 7 8 9 |
# File 'lib/active_record/snapshot/commands/s3.rb', line 6 def initialize(directory:) @connection = create_connection @directory = directory end |
Instance Method Details
#download_to(path) ⇒ Object
15 16 17 |
# File 'lib/active_record/snapshot/commands/s3.rb', line 15 def download_to(path) File.open(path, "wb") { |f| f.write(read(path)) } end |
#read(path) ⇒ Object
19 20 21 |
# File 'lib/active_record/snapshot/commands/s3.rb', line 19 def read(path) connection.get_object(config.bucket, aws_key(path)).body end |
#upload(path) ⇒ Object
11 12 13 |
# File 'lib/active_record/snapshot/commands/s3.rb', line 11 def upload(path) connection.put_object(config.bucket, aws_key(path), File.open(path)) end |