class Riserva::Storage::Dropbox
Public Instance Methods
clean()
click to toggle source
# File lib/riserva/storage/dropbox.rb, line 29 def clean return unless time_to_keep session.list_folder('').entries.each do |file| next unless file.client_modified < time_to_keep.ago session.delete file.path_lower end end
download(remote_file, local_file)
click to toggle source
# File lib/riserva/storage/dropbox.rb, line 16 def download(remote_file, local_file) session.download(File.join('/', remote_file)) do |stream| Pathname.new(local_file).write(stream) end end
upload(local_file, remote_file)
click to toggle source
# File lib/riserva/storage/dropbox.rb, line 9 def upload(local_file, remote_file) session.upload( File.join('/', remote_file), IO.read(local_file) ) end
verify(remote_file, local_file)
click to toggle source
# File lib/riserva/storage/dropbox.rb, line 22 def verify(remote_file, local_file) data = session.get_metadata(File.join('/', remote_file)) checksum = DropboxContentHasher.calculate(local_file) data.content_hash == checksum end
Private Instance Methods
session()
click to toggle source
# File lib/riserva/storage/dropbox.rb, line 41 def session @session ||= ::DropboxApi::Client.new(token) end
token()
click to toggle source
# File lib/riserva/storage/dropbox.rb, line 45 def token JSON.parse(File.read(secrets))['bearer'] end