class Backup::Storage::Upyun
Attributes
bucket[RW]
host[RW]
password[RW]
username[RW]
Public Class Methods
new(model, storage_id = nil, &block)
click to toggle source
Calls superclass method
# File lib/backup/storage/upyun.rb, line 8 def initialize(model, storage_id = nil, &block) super(model, storage_id) @path ||= 'backups' instance_eval(&block) if block_given? end
Private Instance Methods
connection()
click to toggle source
# File lib/backup/storage/upyun.rb, line 18 def connection @connection ||= RestClient::Resource.new("#{@host}/#{@bucket}", :user => @username, :password => @password) end
remove!(package)
click to toggle source
# File lib/backup/storage/upyun.rb, line 35 def remove!(package) remote_path = remote_path_for(package) Logger.info "#{storage_name} removing '#{remote_path}'..." connection.delete(remote_path) end
transfer!()
click to toggle source
# File lib/backup/storage/upyun.rb, line 22 def transfer! remote_path = remote_path_for(@package) @package.filenames.each do |filename| src = File.join(Config.tmp_path, filename) dest = File.join(remote_path, filename) Logger.info "#{storage_name} uploading '#{ dest }' from '#{ src }'..." File.open(src, 'r') do |file| connection[dest].put(file, {}) end end end