Class: ActiveRecord::Snapshot::S3

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/snapshot/commands/s3.rb

Instance Method Summary collapse

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