Class: DropboxApi::Endpoints::ContentUpload

Inherits:
Base
  • Object
show all
Defined in:
lib/dropbox_api/endpoints/content_upload.rb

Instance Method Summary collapse

Methods inherited from Base

add_endpoint

Constructor Details

#initialize(builder) ⇒ ContentUpload

Returns a new instance of ContentUpload.



3
4
5
6
7
# File 'lib/dropbox_api/endpoints/content_upload.rb', line 3

def initialize(builder)
  @connection = builder.build("https://content.dropboxapi.com") do |c|
    c.response :decode_result
  end
end

Instance Method Details

#build_request(params, body) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/dropbox_api/endpoints/content_upload.rb', line 9

def build_request(params, body)
  headers = {
    'Dropbox-API-Arg' => JSON.dump(params),
    'Content-Type' => 'application/octet-stream'
  }

  content_length = get_content_length body
  headers['Content-Length'] = content_length unless content_length.nil?

  return body, headers
end

#perform_request(params, content) ⇒ Object



21
22
23
# File 'lib/dropbox_api/endpoints/content_upload.rb', line 21

def perform_request(params, content)
  process_response(get_response(params, content))
end