Sha256: 2ba0a8b575461428ff656decaf35bf8e61e70aebd5968c4e2f5e1e04554b9f04
Contents?: true
Size: 1.71 KB
Versions: 7
Compression:
Stored size: 1.71 KB
Contents
require 'dropbox_sdk' module BrowseEverything module Driver class DropBox < Base def icon 'dropbox' end def validate_config unless [:app_key,:app_secret].all? { |key| config[key].present? } raise BrowseEverything::InitializationError, "DropBox driver requires :app_key and :app_secret" end end def contents(path='') path.sub!(/^[\/.]+/,'') result = [] unless path.empty? result << BrowseEverything::FileEntry.new( Pathname(path).join('..'), '', '..', 0, Time.now, true ) end result += client.metadata(path)['contents'].collect do |info| path = info['path'] BrowseEverything::FileEntry.new( path, [self.key,path].join(':'), File.basename(path), info['size'], Time.parse(info['modified']), info['is_dir'] ) end result end def link_for(path) [client.media(path)['url'], { expires: 4.hours.from_now, file_name: File.basename(path) }] end def details(path) contents(path).first end def auth_link [ auth_flow.start('drop_box'), @csrf ] end def connect(params,data) @csrf = data @token, user, state = auth_flow.finish(params) @token end def authorized? token.present? end private def auth_flow @csrf ||= {} DropboxOAuth2Flow.new(config[:app_key], config[:app_secret], connector_response_url(config[:url_options]).to_s,@csrf,'token') end def client DropboxClient.new(token) end end end end
Version data entries
7 entries across 7 versions & 1 rubygems