Sha256: ed4128ccbd8c545707be5016f4cbaca7e04f51b3a94c741cae3528ca4bfd3cf0

Contents?: true

Size: 898 Bytes

Versions: 2

Compression:

Stored size: 898 Bytes

Contents

module DropboxApi::Endpoints
  class ContentUpload < DropboxApi::Endpoints::Base
    def initialize(builder)
      @connection = builder.build("https://content.dropboxapi.com") do |c|
        c.response :decode_result
      end
    end

    def build_request(params, content)
      # TODO: It would be better to have a stream object on which we can call
      #       #read, rather than the full file content.
      body = content
      headers = {
        'Dropbox-API-Arg' => JSON.dump(params),
        'Content-Type' => 'application/octet-stream'
      }
      if body.respond_to?(:length)
        headers['Content-Length'] = body.length.to_s
      elsif body.respond_to?(:stat)
        headers['Content-Length'] = body.stat.size.to_s
      end

      return body, headers
    end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dropbox_api-0.1.10 lib/dropbox_api/endpoints/content_upload.rb
dropbox_api-0.1.9 lib/dropbox_api/endpoints/content_upload.rb