Module: Dropbox::API::Client::Files

Included in:
Dropbox::API::Client
Defined in:
lib/dropbox-api/client/files.rb

Instance Method Summary collapse

Instance Method Details

#copy_from_copy_ref(copy_ref, to, options = {}) ⇒ Object



27
28
29
30
31
32
# File 'lib/dropbox-api/client/files.rb', line 27

def copy_from_copy_ref(copy_ref, to, options = {})
  raw.copy({ 
    :from_copy_ref => copy_ref, 
    :to_path => to 
  }.merge(options))
end

#download(path, options = {}) ⇒ Object



8
9
10
11
12
13
# File 'lib/dropbox-api/client/files.rb', line 8

def download(path, options = {})
  root     = options.delete(:root) || Dropbox::API::Config.mode
  path     = Dropbox::API::Util.escape(path)
  url      = ['', "files", root, path].compact.join('/')
  connection.get_raw(:content, url)
end

#upload(path, data, options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/dropbox-api/client/files.rb', line 15

def upload(path, data, options = {})
  root     = options.delete(:root) || Dropbox::API::Config.mode
  query    = Dropbox::API::Util.query(options)
  path     = Dropbox::API::Util.escape(path)
  url      = ['', "files_put", root, path].compact.join('/')
  response = connection.put(:content, "#{url}?#{query}", data, {
    'Content-Type'   => "application/octet-stream",
    "Content-Length" => data.length.to_s
  })
  Dropbox::API::File.init(response, self)
end