Class: DropboxClient

Inherits:
Object
  • Object
show all
Defined in:
lib/dropbox_sdk_v2.rb

Overview

Use this class to make Dropbox API calls. You’ll need to obtain an OAuth 2 access token first; you can get one using either DropboxOAuth2Flow or DropboxOAuth2FlowNoRedirect.

Defined Under Namespace

Classes: ChunkedUploader

Constant Summary collapse

RESERVED_CHARACTERS =

From the oauth spec plus “/”. Slash should not be ecsaped

/[^a-zA-Z0-9\-\.\_\~\/]/

Instance Method Summary collapse

Constructor Details

#initialize(oauth2_access_token, root = "auto", locale = nil) ⇒ DropboxClient

Args:

  • oauth2_access_token: Obtained via DropboxOAuth2Flow or DropboxOAuth2FlowNoRedirect.

  • locale: The user’s current locale (used to localize error messages).



730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
# File 'lib/dropbox_sdk_v2.rb', line 730

def initialize(oauth2_access_token, root="auto", locale=nil)
  if oauth2_access_token.is_a?(String)
    @session = DropboxOAuth2Session.new(oauth2_access_token, locale)
  elsif oauth2_access_token.is_a?(DropboxSession)
    @session = oauth2_access_token
    @session.get_access_token
    if not locale.nil?
      @session.locale = locale
    end
  else
    raise ArgumentError.new("oauth2_access_token doesn't have a valid type")
  end

  @root = root.to_s  # If they passed in a symbol, make it a string

  if not ["dropbox","app_folder","auto"].include?(@root)
    raise ArgumentError.new("root must be :dropbox, :app_folder, or :auto")
  end
  if @root == "app_folder"
    #App Folder is the name of the access type, but for historical reasons
    #sandbox is the URL root component that indicates this
    @root = "sandbox"
  end
end

Instance Method Details

#account_infoObject

Returns some information about the current user’s Dropbox account (the “current user” is the user associated with the access token you’re using).

For a detailed description of what this call returns, visit: www.dropbox.com/developers/reference/api#account-info



760
761
762
763
# File 'lib/dropbox_sdk_v2.rb', line 760

def ()
  response = @session.do_get "/account/info"
  Dropbox::parse_response(response)
end

#add_copy_ref(to_path, copy_ref) ⇒ Object

Adds the file referenced by the copy ref to the specified path

Args:

  • copy_ref: A copy ref string that was returned from a create_copy_ref call. The copy_ref can be created from any other Dropbox account, or from the same account.

  • to_path: The path to where the file will be created.

Returns:

  • A hash with the metadata of the new file.



1423
1424
1425
1426
1427
1428
1429
1430
# File 'lib/dropbox_sdk_v2.rb', line 1423

def add_copy_ref(to_path, copy_ref)
  params = {'from_copy_ref' => copy_ref,
            'to_path' => "#{to_path}",
            'root' => @root}

  response = @session.do_post "/fileops/copy", params
  Dropbox::parse_response(response)
end

#commit_chunked_upload(to_path, upload_id, overwrite = false, parent_rev = nil) ⇒ Object

:nodoc



926
927
928
929
930
931
932
933
934
# File 'lib/dropbox_sdk_v2.rb', line 926

def commit_chunked_upload(to_path, upload_id, overwrite=false, parent_rev=nil)  #:nodoc
  path = "/commit_chunked_upload/#{@root}#{format_path(to_path)}"
  params = {'overwrite' => overwrite.to_s,
            'upload_id' => upload_id,
            'parent_rev' => parent_rev
  }
  headers = nil
  @session.do_post path, params, headers, :content
end

#create_copy_ref(path) ⇒ Object

Creates and returns a copy ref for a specific file. The copy ref can be used to instantly copy that file to the Dropbox of another account.

Args:

  • path: The path to the file for a copy ref to be created on.

Returns:

  • A Hash object that looks like the following example:

    {"expires"=>"Fri, 31 Jan 2042 21:01:05 +0000", "copy_ref"=>"z1X6ATl6aWtzOGq0c3g5Ng"}
    


1408
1409
1410
1411
1412
# File 'lib/dropbox_sdk_v2.rb', line 1408

def create_copy_ref(path)
  path = "/copy_ref/#{@root}#{format_path(path)}"
  response = @session.do_get path
  Dropbox::parse_response(response)
end

#create_oauth2_access_tokenObject

If this DropboxClient was created with an OAuth 1 access token, this method can be used to create an equivalent OAuth 2 access token. This can be used to upgrade your app’s existing access tokens from OAuth 1 to OAuth 2.



775
776
777
778
779
780
781
782
# File 'lib/dropbox_sdk_v2.rb', line 775

def create_oauth2_access_token
  if not @session.is_a?(DropboxSession)
    raise ArgumentError.new("This call requires a DropboxClient that is configured with " \
                            "an OAuth 1 access token.")
  end
  response = @session.do_post "/oauth2/token_from_oauth1"
  Dropbox::parse_response(response)['access_token']
end

#delta(cursor = nil, path_prefix = nil) ⇒ Object

A way of letting you keep a local representation of the Dropbox folder heirarchy. You can periodically call delta() to get a list of “delta entries”, which are instructions on how to update your local state to match the server’s state.

Arguments:

  • cursor: On the first call, omit this argument (or pass in nil). On subsequent calls, pass in the cursor string returned by the previous call.

  • path_prefix: If provided, results will be limited to files and folders whose paths are equal to or under path_prefix. The path_prefix is fixed for a given cursor. Whatever path_prefix you use on the first delta() must also be passed in on subsequent calls that use the returned cursor.

Returns: A hash with three fields.

  • entries: A list of “delta entries” (described below)

  • reset: If true, you should reset local state to be an empty folder before processing the list of delta entries. This is only true only in rare situations.

  • cursor: A string that is used to keep track of your current state. On the next call to delta(), pass in this value to return entries that were recorded since the cursor was returned.

  • has_more: If true, then there are more entries available; you can call delta() again immediately to retrieve those entries. If false, then wait at least 5 minutes (preferably longer) before checking again.

Delta Entries: Each entry is a 2-item list of one of following forms:

  • [path, metadata]: Indicates that there is a file/folder at the given path. You should add the entry to your local state. (The metadata value is the same as what would be returned by the #metadata() call.)

    • If the path refers to parent folders that don’t yet exist in your local state, create those parent folders in your local state. You will eventually get entries for those parent folders.

    • If the new entry is a file, replace whatever your local state has at path with the new entry.

    • If the new entry is a folder, check what your local state has at path. If it’s a file, replace it with the new entry. If it’s a folder, apply the new metadata to the folder, but do not modify the folder’s children.

  • [path, nil]: Indicates that there is no file/folder at the path on Dropbox. To update your local state to match, delete whatever is at path, including any children (you will sometimes also get separate delta entries for each child, but this is not guaranteed). If your local state doesn’t have anything at path, ignore this entry.

Remember: Dropbox treats file names in a case-insensitive but case-preserving way. To facilitate this, the path strings above are lower-cased versions of the actual path. The metadata dicts have the original, case-preserved path.



1320
1321
1322
1323
1324
1325
1326
1327
1328
# File 'lib/dropbox_sdk_v2.rb', line 1320

def delta(cursor=nil, path_prefix=nil)
  params = {
    'cursor' => cursor,
    'path_prefix' => path_prefix,
  }

  response = @session.do_post "/delta", params
  Dropbox::parse_response(response)
end

#delta_latest_cursor(path_prefix = nil) ⇒ Object

Arguments:

  • path_prefix: If present, the returned cursor will be encoded with a path_prefix for the specified path for use with #delta.

Returns: A hash with one field.

  • cursor: A string that encodes the latest server state, as would be returned by #delta when “has_more” is false.



1345
1346
1347
1348
1349
1350
1351
1352
# File 'lib/dropbox_sdk_v2.rb', line 1345

def delta_latest_cursor(path_prefix=nil)
  params = {
    'path_prefix' => path_prefix
  }

  response = @session.do_post "/delta/latest_cursor", params
  Dropbox::parse_response(response)
end

#disable_access_tokenObject

Disables the access token that this DropboxClient is using. If this call succeeds, further API calls using this object will fail.



767
768
769
770
# File 'lib/dropbox_sdk_v2.rb', line 767

def disable_access_token
  @session.do_post "/disable_access_token"
  nil
end

#download(from_path) ⇒ Object

Download a file

Args:

  • from_path: The path to the file to be downloaded

Returns:

  • The HTTPResponse for the file download request.



966
967
968
969
970
971
972
973
# File 'lib/dropbox_sdk_v2.rb', line 966

def download from_path # :nodoc:
  path = "/files/download"
  headers = {"Dropbox-API-Arg" => {'path' => from_path}.to_json}
  response = @session.do_post path, nil, headers, :content
  parsed_response = Dropbox::parse_response(response, raw=true)
   = (response)
  return parsed_response, 
end

#file_copy(from_path, to_path) ⇒ Object

Copy a file or folder to a new location.

Args:

  • from_path: The path to the file or folder to be copied.

  • to_path: The destination path of the file or folder to be copied. This parameter should include the destination filename (e.g. from_path: ‘/test.txt’, to_path: ‘/dir/test.txt’). If there’s already a file at the to_path, this copy will be renamed to be unique.

Returns:



1008
1009
1010
1011
1012
1013
1014
1015
1016
# File 'lib/dropbox_sdk_v2.rb', line 1008

def file_copy(from_path, to_path)
  params = {
    "root" => @root,
    "from_path" => format_path(from_path, false),
    "to_path" => format_path(to_path, false),
  }
  response = @session.do_post "/fileops/copy", params
  Dropbox::parse_response(response)
end

#file_create_folder(path) ⇒ Object

Create a folder.

Arguments:

  • path: The path of the new folder.

Returns:



1027
1028
1029
1030
1031
1032
1033
1034
1035
# File 'lib/dropbox_sdk_v2.rb', line 1027

def file_create_folder(path)
  params = {
    "root" => @root,
    "path" => format_path(path, false),
  }
  response = @session.do_post "/fileops/create_folder", params

  Dropbox::parse_response(response)
end

#file_delete(path) ⇒ Object

Deletes a file

Arguments:

  • path: The path of the file to delete

Returns:



1046
1047
1048
1049
1050
1051
1052
1053
# File 'lib/dropbox_sdk_v2.rb', line 1046

def file_delete(path)
  params = {
    "root" => @root,
    "path" => format_path(path, false),
  }
  response = @session.do_post "/fileops/delete", params
  Dropbox::parse_response(response)
end

#file_move(from_path, to_path) ⇒ Object

Moves a file

Arguments:

  • from_path: The path of the file to be moved

  • to_path: The destination path of the file or folder to be moved If the file or folder already exists, it will be renamed to be unique.

Returns:



1066
1067
1068
1069
1070
1071
1072
1073
1074
# File 'lib/dropbox_sdk_v2.rb', line 1066

def file_move(from_path, to_path)
  params = {
    "root" => @root,
    "from_path" => format_path(from_path, false),
    "to_path" => format_path(to_path, false),
  }
  response = @session.do_post "/fileops/move", params
  Dropbox::parse_response(response)
end

#format_path(path, escape = true) ⇒ Object

:nodoc:



1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
# File 'lib/dropbox_sdk_v2.rb', line 1470

def format_path(path, escape=true) # :nodoc:
  path = path.gsub(/\/+/,"/")
  # replace multiple slashes with a single one

  path = path.gsub(/^\/?/,"/")
  # ensure the path starts with a slash

  path.gsub(/\/?$/,"")
  # ensure the path doesn't end with a slash

  return URI.escape(path, RESERVED_CHARACTERS) if escape
  path
end

#get_chunked_uploader(file_obj, total_size) ⇒ Object

Returns a ChunkedUploader object.

Args:

  • file_obj: The file-like object to be uploaded. Must support .read()

  • total_size: The total size of file_obj



838
839
840
# File 'lib/dropbox_sdk_v2.rb', line 838

def get_chunked_uploader(file_obj, total_size)
  ChunkedUploader.new(self, file_obj, total_size)
end

#get_file(from_path, rev = nil) ⇒ Object

Download a file

Args:

  • from_path: The path to the file to be downloaded

  • rev: A previous revision value of the file to be downloaded

Returns:

  • The file contents.

GEM 8/18/2016 - DEPRECIATED



954
955
956
957
# File 'lib/dropbox_sdk_v2.rb', line 954

def get_file(from_path, rev=nil)
  response = get_file_impl(from_path, rev)
  Dropbox::parse_response(response, raw=true)
end

#longpoll_delta(cursor, timeout = 30) ⇒ Object

Calls the long-poll endpoint which waits for changes on an account. In conjunction with #delta, this call gives you a low-latency way to monitor an account for file changes.

The passed in cursor can only be acquired via a call to #delta

Arguments:

  • cursor: A delta cursor as returned from a call to #delta

  • timeout: An optional integer indicating a timeout, in seconds. The default value is 30 seconds, which is also the minimum allowed value. The maximum is 480 seconds.

Returns: A hash with one or two fields.

  • changes: A boolean value indicating whether new changes are available.

  • backoff: If present, indicates how many seconds your code should wait before calling #longpoll_delta again.



1370
1371
1372
1373
1374
1375
1376
1377
1378
# File 'lib/dropbox_sdk_v2.rb', line 1370

def longpoll_delta(cursor, timeout=30)
  params = {
    'cursor' => cursor,
    'timeout' => timeout
  }

  response = @session.do_get "/longpoll_delta", params, :notify
  Dropbox::parse_response(response)
end

#media(path) ⇒ Object

Returns a direct link to a media file All of Dropbox’s API methods require OAuth, which may cause problems in situations where an application expects to be able to hit a URL multiple times (for example, a media player seeking around a video file). This method creates a time-limited URL that can be accessed without any authentication.

Arguments:

  • path: The file to stream.

Returns:

  • A Hash object that looks like the following:

    {'url': 'https://dl.dropboxusercontent.com/1/view/abcdefghijk/example', 'expires': 'Thu, 16 Sep 2011 01:01:25 +0000'}
    


1198
1199
1200
1201
# File 'lib/dropbox_sdk_v2.rb', line 1198

def media(path)
  response = @session.do_get "/media/#{@root}#{format_path(path)}"
  Dropbox::parse_response(response)
end

#metadata(path, file_limit = 25000, list = true, hash = nil, rev = nil, include_deleted = false, include_media_info = false) ⇒ Object

Retrives metadata for a file or folder

Arguments:

  • path: The path to the file or folder.

  • list: Whether to list all contained files (only applies when path refers to a folder).

  • file_limit: The maximum number of file entries to return within a folder. If the number of files in the directory exceeds this limit, an exception is raised. The server will return at max 25,000 files within a folder.

  • hash: Every directory listing has a hash parameter attached that can then be passed back into this function later to save on bandwidth. Rather than returning an unchanged folder’s contents, if the hash matches a DropboxNotModified exception is raised.

  • rev: Optional. The revision of the file to retrieve the metadata for. This parameter only applies for files. If omitted, you’ll receive the most recent revision metadata.

  • include_deleted: Specifies whether to include deleted files in metadata results.

  • include_media_info: Specifies to include media info, such as time_taken for photos

Returns:



1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
# File 'lib/dropbox_sdk_v2.rb', line 1100

def (path, file_limit=25000, list=true, hash=nil, rev=nil, include_deleted=false, include_media_info=false)
  params = {
    "file_limit" => file_limit.to_s,
    "list" => list.to_s,
    "include_deleted" => include_deleted.to_s,
    "hash" => hash,
    "rev" => rev,
    "include_media_info" => include_media_info
  }

  response = @session.do_get "/metadata/#{@root}#{format_path(path)}", params
  if response.kind_of? Net::HTTPRedirection
    raise DropboxNotModified.new("metadata not modified")
  end
  Dropbox::parse_response(response)
end

#partial_chunked_upload(data, upload_id = nil, offset = nil) ⇒ Object

:nodoc



936
937
938
939
940
941
942
943
# File 'lib/dropbox_sdk_v2.rb', line 936

def partial_chunked_upload(data, upload_id=nil, offset=nil)  #:nodoc
  params = {
    'upload_id' => upload_id,
    'offset' => offset,
  }
  headers = {'Content-Type' => "application/octet-stream"}
  @session.do_put '/chunked_upload', params, headers, data, :content
end

#preview(path, rev = nil) ⇒ Object

Download a PDF or HTML preview for a file.

Arguments:

  • path: The path to the file to be previewed.

  • rev: Optional. The revision of the file to retrieve the metadata for. If omitted, you’ll get the most recent version.

Returns:

  • The preview data



1232
1233
1234
1235
1236
1237
# File 'lib/dropbox_sdk_v2.rb', line 1232

def preview(path, rev=nil)
  path = "/previews/#{@root}#{format_path(path)}"
  params = { 'rev' => rev }
  response = @session.do_get path, params, :content
  Dropbox::parse_response(response, raw=true)
end

#restore(path, rev) ⇒ Object

Restore a file to a previous revision.

Arguments:

  • path: The file to restore. Note that folders can’t be restored.

  • rev: A previous rev value of the file to be restored to.

Returns:



1177
1178
1179
1180
1181
1182
1183
1184
# File 'lib/dropbox_sdk_v2.rb', line 1177

def restore(path, rev)
  params = {
    'rev' => rev.to_s
  }

  response = @session.do_post "/restore/#{@root}#{format_path(path)}", params
  Dropbox::parse_response(response)
end

#revisions(path, rev_limit = 1000) ⇒ Object

Retrive revisions of a file

Arguments:

  • path: The file to fetch revisions for. Note that revisions are not available for folders.

  • rev_limit: The maximum number of file entries to return within a folder. The server will return at max 1,000 revisions.

Returns:



1158
1159
1160
1161
1162
1163
1164
1165
# File 'lib/dropbox_sdk_v2.rb', line 1158

def revisions(path, rev_limit=1000)
  params = {
    'rev_limit' => rev_limit.to_s
  }

  response = @session.do_get "/revisions/#{@root}#{format_path(path)}", params
  Dropbox::parse_response(response)
end

#save_url(to_path, url) ⇒ Object

Save a file from the specified URL into Dropbox. If the given path already exists, the file will be renamed to avoid the conflict (e.g. myfile (1).txt).

Args:

  • to_path: The path in Dropbox where the file will be saved (e.g. /folder/file.ext).

  • url: The URL to be fetched.

Returns:

  • A dictionary with a status and job. The status is as defined in the

/save_url_job documentation. The job field gives a job ID that can be used with the /save_url_job endpoint to check the job’s status. Check www.dropbox.com/developers/core/docs#save-url for more info.

{"status": "PENDING", "job": "PEiuxsfaISEAAAAAAADwzg"}


1445
1446
1447
1448
1449
1450
# File 'lib/dropbox_sdk_v2.rb', line 1445

def save_url(to_path, url)
  params = { 'url' => url }

  response = @session.do_post "/save_url/auto#{format_path(to_path, true)}", params
  Dropbox::parse_response(response)
end

#save_url_job(job_id) ⇒ Object

Check the status of a save URL job.

Args:

  • job_id: A job ID returned from /save_url.

Returns: *A dictionary with a status field with one of the following values: PENDING, DOWNLOADING, COMPLETE, FAILED Check www.dropbox.com/developers/core/docs#save-url for more info.

{"status": "FAILED", "error": "Job timed out"}


1462
1463
1464
1465
# File 'lib/dropbox_sdk_v2.rb', line 1462

def save_url_job(job_id)
  response = @session.do_get "/save_url_job/#{job_id}"
  Dropbox::parse_response(response)
end

#search(path, query, file_limit = 1000) ⇒ Object

Search directory for filenames matching query

Arguments:

  • path: The directory to search within

  • query: The query to search on (3 character minimum)

  • file_limit: The maximum number of file entries to return/ If the number of files exceeds this limit, an exception is raised. The server will return at max 1,000

  • include_deleted: Whether to include deleted files in search results

Returns:



1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
# File 'lib/dropbox_sdk_v2.rb', line 1131

def search(path, query, file_limit=1000)
  params = {
    'path' => path,
    'query' => query,
    'start' => 0,
    'max_results' => file_limit,
    'mode' => 'filename'
  }.to_json
  headers = {"Content-Type" => "application/json"}

  response = @session.do_post "/files/search", params, headers
  Dropbox::parse_response(response)
end

#shares(path, short_url = true) ⇒ Object

Get a URL to share a media file Shareable links created on Dropbox are time-limited, but don’t require any authentication, so they can be given out freely. The time limit should allow at least a day of shareability, though users have the ability to disable a link from their account if they like.

Arguments:

  • path: The file to share.

  • short_url: When true (default), the url returned will be shortened using the Dropbox url shortener. If false, the url will link directly to the file’s preview page.

Returns:

  • A Hash object that looks like the following example:

    {'url': 'https://db.tt/c0mFuu1Y', 'expires': 'Tue, 01 Jan 2030 00:00:00 +0000'}
    

    For a detailed description of what this call returns, visit:

    https://www.dropbox.com/developers/reference/api#shares
    


1219
1220
1221
1222
# File 'lib/dropbox_sdk_v2.rb', line 1219

def shares(path, short_url=true)
  response = @session.do_get "/shares/#{@root}#{format_path(path)}", {"short_url"=>short_url}
  Dropbox::parse_response(response)
end

#thumbnail(from_path, size = 'large') ⇒ Object

Download a thumbnail for an image.

Arguments:

  • from_path: The path to the file to be thumbnailed.

  • size: A string describing the desired thumbnail size. At this time, ‘small’ (32x32), ‘medium’ (64x64), ‘large’ (128x128), ‘s’ (64x64), ‘m’ (128x128), ‘l’ (640x640), and ‘xl’ (1024x1024) are officially supported sizes. Check www.dropbox.com/developers/reference/api#thumbnails for more details. [defaults to large]

Returns:

  • The thumbnail data



1250
1251
1252
1253
# File 'lib/dropbox_sdk_v2.rb', line 1250

def thumbnail(from_path, size='large')
  response = thumbnail_impl(from_path, size)
  Dropbox::parse_response(response, raw=true)
end

#thumbnail_and_metadata(from_path, size = 'large') ⇒ Object

Download a thumbnail for an image along with the image’s metadata.

Arguments:

  • from_path: The path to the file to be thumbnailed.

  • size: A string describing the desired thumbnail size. See thumbnail() for details.

Returns:

  • The thumbnail data

  • The metadata for the image as a hash



1264
1265
1266
1267
1268
1269
# File 'lib/dropbox_sdk_v2.rb', line 1264

def (from_path, size='large')
  response = thumbnail_impl(from_path, size)
  parsed_response = Dropbox::parse_response(response, raw=true)
   = (response)
  return parsed_response, 
end

#upload(to_path, file_obj, mode = 'add') ⇒ Object

Uploads a file to a server. This uses the HTTP PUT upload method for simplicity

Args:

  • to_path: The directory path to upload the file to. If the destination directory does not yet exist, it will be created.

  • file_obj: A file-like object to upload. If you would like, you can pass a string as file_obj.

  • overwrite: Whether to overwrite an existing file at the given path. [default is False] If overwrite is False and a file already exists there, Dropbox will rename the upload to make sure it doesn’t overwrite anything. You must check the returned metadata to know what this new name is. This field should only be True if your intent is to potentially clobber changes to a file that you don’t know about.

  • parent_rev: The rev field from the ‘parent’ of this upload. [optional] If your intent is to update the file at the given path, you should pass the parent_rev parameter set to the rev value from the most recent metadata you have of the existing file at that path. If the server has a more recent version of the file at the specified path, it will automatically rename your uploaded file, spinning off a conflict. Using this parameter effectively causes the overwrite parameter to be ignored. The file will always be overwritten if you send the most-recent parent_rev, and it will never be overwritten you send a less-recent one.

Returns:

  • a Hash containing the metadata of the newly uploaded file. The file may have a different name if it conflicted.

Simple Example

client = DropboxClient(oauth2_access_token)
#session is a DropboxSession I've already authorized
client.put_file('/test_file_on_dropbox', open('/tmp/test_file'))

This will upload the “/tmp/test_file” from my computer into the root of my App’s app folder and call it “test_file_on_dropbox”. The file will not overwrite any pre-existing file.



817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
# File 'lib/dropbox_sdk_v2.rb', line 817

def upload(to_path, file_obj, mode='add')
  path = "/files/upload"
  params = {
    'path' => to_path,
    'mode' => mode,
    'autorename' => false,
    'mute' => false
  }

  headers = {"Content-Type" => "application/octet-stream",
             "Dropbox-API-Arg" => params.to_json}
  response = @session.do_post path, file_obj, headers, :content

  Dropbox::parse_response(response)
end