Class: Breadbox::DropboxClient

Inherits:
Client
  • Object
show all
Defined in:
lib/breadbox/dropbox_client.rb

Instance Attribute Summary

Attributes inherited from Client

#configuration

Instance Method Summary collapse

Methods inherited from Client

#client, #initialize, #root_path

Constructor Details

This class inherits a constructor from Breadbox::Client

Instance Method Details

#access_tokenObject



6
7
8
# File 'lib/breadbox/dropbox_client.rb', line 6

def access_token
  configuration.dropbox_access_token
end

#upload(options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/breadbox/dropbox_client.rb', line 10

def upload(options = {})
  path      = options[:path]
  file      = options[:file]
  filename  = options[:filename]  || File.basename(file)
  overwrite = options[:overwrite] || false
  share     = options[:share]

  filepath  = filepath_from_paths_and_filename(root_path, path, filename)
  result    = client.put_file(filepath, file, overwrite)

  if share && result
    share_hash = client.shares(result["path"])
    share_hash["url"]
  elsif result
    result["path"]
  end
end