Class: Savior::Storage

Inherits:
Object
  • Object
show all
Defined in:
lib/savior/storage.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Storage

Returns a new instance of Storage.



5
6
7
8
9
10
11
12
13
# File 'lib/savior/storage.rb', line 5

def initialize(options={})
  @access_key_id = options[:access_key_id] || ENV['AMAZON_ACCESS_KEY_ID']
  @secret_access_key = options[:secret_access_key] || ENV['AMAZON_SECRET_ACCESS_KEY']
  @bucket_name = options[:bucket_name]
  @s3 = AWS::S3.new(
    :access_key_id     => @access_key_id,
    :secret_access_key => @secret_access_key
  )
end

Instance Method Details

#upload_file(db_snapshot_file, remove_temp_file = false) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/savior/storage.rb', line 15

def upload_file(db_snapshot_file, remove_temp_file = false)
  s3_snapshot_object = @s3.buckets[@bucket_name].
    objects[db_snapshot_file]
  s3_snapshot_object.write(File.read(db_snapshot_file))
  if remove_temp_file
    File.delete(db_snapshot_file)
  end
end