Class: Snapshooter::Storage::S3
- Defined in:
- lib/snapshooter/storage/s3.rb
Instance Method Summary collapse
Methods inherited from Base
#initialize, #restore, #snapshot!
Methods included from Log
Constructor Details
This class inherits a constructor from Snapshooter::Base
Instance Method Details
#get(filename, &block) ⇒ Object
31 32 33 34 35 36 |
# 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, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# 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 |