class DropboxApi::Endpoints::ContentUpload
Public Class Methods
new(builder)
click to toggle source
# File lib/dropbox_api/endpoints/content_upload.rb, line 4 def initialize(builder) @connection = builder.build('https://content.dropboxapi.com') do |c| c.response :decode_result end end
Public Instance Methods
build_request(params, body)
click to toggle source
# File lib/dropbox_api/endpoints/content_upload.rb, line 10 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)
click to toggle source
# File lib/dropbox_api/endpoints/content_upload.rb, line 22 def perform_request(params, content) process_response(get_response(params, content)) end
Private Instance Methods
get_content_length(content)
click to toggle source
# File lib/dropbox_api/endpoints/content_upload.rb, line 28 def get_content_length(content) if content.respond_to?(:bytesize) content.bytesize.to_s elsif content.respond_to?(:length) content.length.to_s elsif content.respond_to?(:stat) content.stat.size.to_s end end