class Snapshooter::Storage::S3
Public Instance Methods
get(filename, &block)
click to toggle source
# File lib/snapshooter/storage/s3.rb, line 31 def get(filename, &block) directory = connection.directories.get(bucket) file = directory.files.get(filename) with_tempfile file.body, &block end
save(filename) { |path| ... }
click to toggle source
# File lib/snapshooter/storage/s3.rb, line 7 def save(filename, &block) with_log("Save #{bucket}/#{filename} to S3") do directory = connection.directories.create( :key => bucket, :public => false ) file = Tempfile.new("snapshooter_s3_storage") file.close begin yield file.path directory.files.create( :key => filename, :body => File.open(file.path), :public => false ) ensure file.unlink end end end
Private Instance Methods
bucket()
click to toggle source
# File lib/snapshooter/storage/s3.rb, line 40 def bucket "#{Snapshooter.environment}-snapshots-#{Snapshooter.application_name}" end
connection()
click to toggle source
# File lib/snapshooter/storage/s3.rb, line 44 def connection Fog::Storage[:aws] end
with_tempfile(data) { |path| ... }
click to toggle source
# File lib/snapshooter/storage/s3.rb, line 48 def with_tempfile(data) file = Tempfile.new("snapshooter_s3_storage") file.write data file.close yield file.path file.unlink end