Class: Backup::Storage::Qiniu
- Inherits:
-
Base
- Object
- Base
- Backup::Storage::Qiniu
- Defined in:
- lib/backup/storage/qiniu.rb
Instance Attribute Summary collapse
-
#access_key ⇒ Object
Returns the value of attribute access_key.
-
#access_secret ⇒ Object
Returns the value of attribute access_secret.
-
#bucket ⇒ Object
Returns the value of attribute bucket.
-
#path ⇒ Object
Returns the value of attribute path.
-
#upload_token ⇒ Object
Returns the value of attribute upload_token.
Instance Method Summary collapse
-
#initialize(model, storage_id = nil) ⇒ Qiniu
constructor
A new instance of Qiniu.
- #remove!(pkg) ⇒ Object
- #transfer! ⇒ Object
Constructor Details
#initialize(model, storage_id = nil) ⇒ Qiniu
Returns a new instance of Qiniu.
14 15 16 17 18 19 |
# File 'lib/backup/storage/qiniu.rb', line 14 def initialize(model, storage_id = nil) super(model, storage_id) @bucket ||= 'backups' @path ||= '' end |
Instance Attribute Details
#access_key ⇒ Object
Returns the value of attribute access_key.
9 10 11 |
# File 'lib/backup/storage/qiniu.rb', line 9 def access_key @access_key end |
#access_secret ⇒ Object
Returns the value of attribute access_secret.
9 10 11 |
# File 'lib/backup/storage/qiniu.rb', line 9 def access_secret @access_secret end |
#bucket ⇒ Object
Returns the value of attribute bucket.
11 12 13 |
# File 'lib/backup/storage/qiniu.rb', line 11 def bucket @bucket end |
#path ⇒ Object
Returns the value of attribute path.
12 13 14 |
# File 'lib/backup/storage/qiniu.rb', line 12 def path @path end |
#upload_token ⇒ Object
Returns the value of attribute upload_token.
10 11 12 |
# File 'lib/backup/storage/qiniu.rb', line 10 def upload_token @upload_token end |
Instance Method Details
#remove!(pkg) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/backup/storage/qiniu.rb', line 21 def remove!(pkg) remote_path = remote_path_for(pkg) establish_connection! package.filenames.each do |remote_file| Logger.info "#{storage_name} started removing " + "'#{ remote_file }' from bucket '#{ bucket }'." key = File.join(remote_path, remote_file) unless ::Qiniu::RS.delete(bucket, key) raise "delete '#{key}' failed" end end end |
#transfer! ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/backup/storage/qiniu.rb', line 34 def transfer! if access_key and access_secret transfer_by_secret! else transfer_by_upload_token! end end |