Class: DropboxApi::Endpoints::Files::UploadSessionStart

Inherits:
ContentUpload show all
Includes:
OptionsValidator
Defined in:
lib/dropbox_api/endpoints/files/upload_session_start.rb

Constant Summary collapse

Method =
:post
Path =
"/2/files/upload_session/start".freeze
ResultType =
DropboxApi::Results::UploadSessionStart
ErrorType =
nil

Instance Method Summary collapse

Methods included from OptionsValidator

#validate_options

Methods inherited from ContentUpload

#build_request, #initialize, #perform_request

Methods inherited from Base

add_endpoint

Constructor Details

This class inherits a constructor from DropboxApi::Endpoints::ContentUpload

Instance Method Details

#upload_session_start(content, options = {}) ⇒ DropboxApi::Metadata::UploadSessionCursor

Upload sessions allow you to upload a single file in one or more requests, for example where the size of the file is greater than 150 MB.

This call starts a new upload session with the given data. You can then use Client#upload_session_append_v2 to add more data and Client#upload_session_finish to save all the data to a file in Dropbox.

A single request should not upload more than 150 MB of file contents.

Options Hash (options):

  • close (Boolean)

    If true, the current session will be closed, at which point you won't be able to call Client#upload_session_append_v2 anymore with the current session. The default for this field is false.

Returns:


25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/dropbox_api/endpoints/files/upload_session_start.rb', line 25

add_endpoint :upload_session_start do |content, options = {}|
  validate_options([
    :close
  ], options)

  session = perform_request(options, content)

  DropboxApi::Metadata::UploadSessionCursor.new({
    "session_id" => session.session_id,
    "offset" => content.bytesize
  })
end