Magpie.Files.UploadSession (Magpie v0.1.0)

Copy Markdown View Source

This namespace contains endpoints and data types for basic file operations.

Summary

Functions

Append more data to an upload session.

Append data to multiple upload sessions in a single request. data is the concatenated content for all sessions (iodata), split according to each entry's "length"; entries are maps with "cursor", "length" and optionally "close".

Appends data (iodata) to the upload session session_id at offset (the number of bytes already uploaded to the session).

Finish an upload session and save the uploaded data to the given file path.

This route helps you commit many files at once into a user's Dropbox.

Returns the status of an asynchronous job for upload_session/finish_batch. If success, it returns list of result for each entry.

Finishes the upload session session_id, committing the uploaded bytes to the path given in commit (a map with the /files/upload argument fields, e.g. %{"path" => "/backup.zip", "mode" => "add"}). Optional trailing data is appended before committing.

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.

Start multiple upload sessions at once. opts accepts "session_type" (%{".tag" => "sequential"} or %{".tag" => "concurrent"}).

Starts an upload session with data (iodata) as its first bytes. Returns {:ok, %{"session_id" => id}} on success.

Functions

append(client, session_id, close, file, offset \\ 0)

Append more data to an upload session.

Example

Magpie.Files.UploadSession.append(client, "AAAAAAAADipnX-8-d8-V4g", false, "")

More info at: https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-append_v2

append_batch(client, entries, data)

Append data to multiple upload sessions in a single request. data is the concatenated content for all sessions (iodata), split according to each entry's "length"; entries are maps with "cursor", "length" and optionally "close".

More info at: https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-append_batch

append_data(client, session_id, offset, data, close \\ false)

Appends data (iodata) to the upload session session_id at offset (the number of bytes already uploaded to the session).

More info at: https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-append_v2

finish(client, session_id, path, file, offset \\ 0, mode \\ "add", autorename \\ true, mute \\ false)

Finish an upload session and save the uploaded data to the given file path.

Example

Magpie.Files.UploadSession.finish(client, "AAAAAAAADipnX-8-d8-V4g", "", "")

More info at: https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-finish

finish_batch(client, entries)

This route helps you commit many files at once into a user's Dropbox.

Example

entry = %{ "cursor" => %{ "session_id" => "AAAAAAAADipnX-8-d8-V4g", "offset" => 0}, "commit" => %{ "path" => "/Homework/math/Matrices.txt" }} entries = [entry] Magpie.Files.UploadSession.finish_batch client, entries

More info at: https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-finish_batch_v2

finish_batch_check(client, async_job_id)

Returns the status of an asynchronous job for upload_session/finish_batch. If success, it returns list of result for each entry.

Example

Magpie.Files.UploadSession.finish_batch_check(client, "")

More info at: https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-finish_batch-check

finish_data(client, session_id, offset, commit, data \\ "")

Finishes the upload session session_id, committing the uploaded bytes to the path given in commit (a map with the /files/upload argument fields, e.g. %{"path" => "/backup.zip", "mode" => "add"}). Optional trailing data is appended before committing.

More info at: https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-finish

start(client, close, file)

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.

Example

Magpie.Files.UploadSession.start(client, false, "/Tmp")

More info at: https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-start

start_batch(client, num_sessions, opts \\ %{})

Start multiple upload sessions at once. opts accepts "session_type" (%{".tag" => "sequential"} or %{".tag" => "concurrent"}).

More info at: https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-start_batch

start_data(client, data, close \\ false)

Starts an upload session with data (iodata) as its first bytes. Returns {:ok, %{"session_id" => id}} on success.

Use this (together with append_data/5 and finish_data/5) when you control the chunks yourself; for the common "upload this local file" case prefer Magpie.Files.upload_file/4, which orchestrates the whole session automatically.

More info at: https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-start