# `Magpie.Files.UploadSession`
[🔗](https://github.com/alexcassol/magpie/blob/v0.5.1/lib/magpie/files/upload_session.ex#L1)

Upload sessions (`/files/upload_session/*`) — uploading a file in several
requests, for content above the 150 MB single-request limit.

`finish/8` and `finish_data/5` return the committed file's
`Magpie.FileMetadata`. The batch variants (`finish_batch/2`,
`finish_batch_check/2`) keep Dropbox's per-entry result maps, since each
entry is a `success`/`failure` union rather than plain metadata.

# `append`

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`

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`

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`

Finish an upload session and save the uploaded data to the given file path.
Returns the committed file's `Magpie.FileMetadata`.

## 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`

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`

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`

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. Returns the committed file's
`Magpie.FileMetadata`.

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

# `start`

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`

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`

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
