Sha256: 9f681789ef62056f849fc8063349f7cf4a19fe54585657279c2bcbd12d9dc1ed
Contents?: true
Size: 856 Bytes
Versions: 5
Compression:
Stored size: 856 Bytes
Contents
# frozen_string_literal: true require 'json' require 'dropbox_api' require 'dropbox_content_hasher' module Riserva::Storage class Dropbox < ApplicationStorage def upload(local_file, remote_file) session.upload( File.join('/', remote_file), IO.read(local_file) ) end def download(remote_file, local_file) session.download(File.join('/', remote_file)) do |stream| Pathname.new(local_file).write(stream) end end 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 def session @session ||= ::DropboxApi::Client.new(token) end def token JSON.parse(File.read(secrets))['bearer'] end end end
Version data entries
5 entries across 5 versions & 1 rubygems