Uploads: upload for files up to the session threshold, and upload
sessions (upload_session/start, append_v2, finish) in chunks for
large files. upload switches to a session automatically above
opts.session-threshold (default 32 MiB; Dropbox's single-request
cap is 150 MiB).
Content may be Bytes (sent verbatim), a Str (its UTF-8 bytes), or a
Map/Vec (sent as JSON). Bodies are sent as Bytes, so binary data
(0x00, 0xFF, invalid UTF-8) arrives intact. Every request carries the
content_hash of the bytes it sends, so Dropbox rejects data
corrupted in transit (opts.verify: false turns that off).
Sessions. Chunks default to 16 MiB (opts.chunk-size, rounded
down to a multiple of 4 MiB, at most 148 MiB). A session lives for 7
days. When a chunk fails, the Err is an UploadError carrying
session-id and offset: call resume-upload with the same content
to continue from there, from a later run or a task retry. An append
whose response was lost but whose data arrived (Dropbox answers
incorrect_offset with the expected next offset) counts as done.
Data transport limit. Every upload, start, append and finish call
counts as a data transport call for Dropbox Business teams with a
monthly limit; over it they fail with 403 (::dropbox::api/is-transport-limit).
Bigger chunks mean fewer calls.
Scopes. files.content.write.
Values
BLOCK
BLOCK: Int 4194304
COMMIT_KEYS
COMMIT_KEYS: Vec [
"autorename",
"client_modified",
"mute",
"strict_conflict",
"property_groups"
]
DEFAULT_CHUNK_SIZE
DEFAULT_CHUNK_SIZE: Int 16777216
DEFAULT_SESSION_THRESHOLD
DEFAULT_SESSION_THRESHOLD: Int 33554432
MAX_CHUNK_SIZE
MAX_CHUNK_SIZE: Int 155189248
UPLOAD_LOCAL_KEYS
UPLOAD_LOCAL_KEYS: Vec [
"mode",
"rev",
"session",
"session-threshold",
"chunk-size",
"verify",
"session_type"
]
Functions
align-chunk-size
fn (size: Int): Int
Round a chunk size down to a multiple of 4 MiB (at least 4 MiB, at most 148 MiB so a request stays under Dropbox's 150 MiB cap).
Example
::dropbox::upload/align-chunk-size(10000000) // 8388608
::dropbox::upload/align-chunk-size(1) // 4194304
append-outcome
fn (result: Result, offset: Int, sent: Int): Int
Classify an append response (pure): the new offset on success; also
the new offset when Dropbox answers incorrect_offset with exactly
offset + sent (the data had arrived but the response was lost); an
Err otherwise.
Example
::dropbox::upload/append-outcome({}, 0, 4) // 4
// The data arrived but the response was lost
lost err({error: {".tag": "incorrect_offset", correct_offset: 4}})
::dropbox::upload/append-outcome(lost, 0, 4) // 4
append-upload-session
fn (session-id: Str, offset: Int, content: Any): Int
fn (session-id: Str, offset: Int, content: Any, opts: Map): Int
POST files/upload_session/append_v2 - send the next chunk at offset
(the bytes already sent). Returns the next offset (Int). A lost response
whose data arrived is recognised (see append-outcome). Options:
close, verify.
Example
session-id ::dropbox::upload/start-upload-session(Bytes("part 1"))
offset ::dropbox::upload/append-upload-session(session-id, 6, Bytes("part 2"))
offset
chunk-bounds
fn (offset: Int, chunk-size: Int, total: Int): Vec
The [start, end) byte range of the chunk starting at offset (pure):
chunk-bounds(0, 4, 10) is [0, 4], the last chunk is short.
Example
::dropbox::upload/chunk-bounds(0, 4, 10) // [0, 4]
::dropbox::upload/chunk-bounds(8, 4, 10) // [8, 10]
commit-info
fn (path: Str, opts: Map): Map
The CommitInfo for a path (pure): path, mode (see write-mode,
from opts.mode / opts.rev) and autorename, client_modified
("2026-11-01T12:00:00Z"), mute, strict_conflict, property_groups
from opts.
Example
::dropbox::upload/commit-info("Reports/q3.csv", {mode: "overwrite", autorename: true})
// {autorename: true, path: "/Reports/q3.csv", mode: "overwrite"}
finish-upload-session
fn (session-id: Str, offset: Int, content: Any, path: Str): Map
fn (session-id: Str, offset: Int, content: Any, path: Str, opts: Map): Map
POST files/upload_session/finish - send the last chunk at offset (may
be empty) and commit the file to path. Returns the file's metadata.
Commit options as for upload.
Example
session-id ::dropbox::upload/start-upload-session(Bytes("part 1"))
file ::dropbox::upload/finish-upload-session(session-id, 6, Bytes("part 2"), "/logs/run.txt", {mode: "overwrite"})
file.content_hash
resume-upload
fn (session-id: Str, offset: Int, content: Any, path: Str): Map
fn (session-id: Str, offset: Int, content: Any, path: Str, opts: Map): Map
Continue an interrupted upload session: send content (the whole
file again) from offset (from the UploadError) and commit to
path. Sessions expire 7 days after start; an expired one fails
with lookup_failed/not_found, so start over with upload.
Example
big ::hot::file/read-file-bytes("/tmp/video.mp4")
result ::dropbox::upload/upload-session("/Videos/talk.mp4", big)
// Continue from where the failed session stopped
failed if(is-err(result), err-value(result), null)
if(is-some(failed), ::dropbox::upload/resume-upload(failed.session-id, failed.offset, big, "/Videos/talk.mp4"), result)
session-cursor
fn (session-id: Str, offset: Int): Map
An UploadSessionCursor (pure): {session_id, offset}.
Example
::dropbox::upload/session-cursor("AAFv3xQ", 8) // {session_id: "AAFv3xQ", offset: 8}
start-upload-session
fn (content: Any): Str
fn (content: Any, opts: Map): Str
POST files/upload_session/start - open a session with the first chunk of
content (may be empty). Returns the session_id (a Str). Options:
session_type ("sequential" default, or "concurrent"), verify.
Example
session-id ::dropbox::upload/start-upload-session(Bytes("part 1"))
session-id
to-bytes
fn (content: Any): Bytes
Upload content as Bytes: Bytes pass through, a Str becomes its UTF-8 bytes, null is empty, and anything else is JSON-encoded.
Example
length(::dropbox::upload/to-bytes("hello")) // 5
length(::dropbox::upload/to-bytes(null)) // 0
upload
fn (path: Str, content: Any): Map
fn (path: Str, content: Any, opts: Map): Map
Upload a file to path and return its metadata. Content up to
opts.session-threshold (default 32 MiB) goes in one request; larger
content (or session: true) uses an upload session.
Options: mode ("add" default, "overwrite", "update" with
rev), rev, autorename, client_modified, mute,
strict_conflict, session, session-threshold, chunk-size,
verify (default true: send content_hash), plus credentials.
meta-data ::dropbox::upload/upload("/Reports/q3.csv", "region,total\nwest,42\n", {mode: "overwrite"})
meta-data.content_hash
upload-arg
fn (path: Str, data: Bytes, opts: Map): Map
The files/upload argument (pure): commit-info plus content_hash of
data (unless opts.verify is false).
Example
::dropbox::upload/upload-arg("/a.txt", Bytes("hello"), {verify: false}) // {path: "/a.txt", mode: "add"}
::dropbox::upload/upload-arg("/a.txt", Bytes("hello"), {}).content_hash // "9595c9df90075148eb06860365df33584b75bff782a510c6cd4883a419833d50"
upload-session
fn (path: Str, content: Any): Map
fn (path: Str, content: Any, opts: Map): Map
Upload content to path through an upload session: start with
the first chunk, append_v2 for the middle chunks, finish with the
last chunk and the commit. Returns the file's metadata, or an Err
carrying an UploadError with the session-id and offset to
resume-upload from.
big ::hot::file/read-file-bytes("/tmp/video.mp4")
meta-data ::dropbox::upload/upload-session("/Videos/talk.mp4", big, {chunk-size: 33554432})
upload-single
fn (path: Str, content: Any, opts: Map): Map
POST files/upload (content host) - upload content (at most 150 MiB) in
one request. Returns the file's metadata. Options as for upload.
Example
file ::dropbox::upload/upload-single("/notes/today.md", "# Today\n", {mode: "overwrite"})
file.rev
write-mode
fn (mode: Any, rev: Str?): Any
The WriteMode for a commit (pure): "add" (default; never
overwrite, fail or autorename on a conflict), "overwrite", or
"update" with rev (overwrite only if the file is still at rev,
the safe way to save edits). A Map is passed through. A rev with no
mode means update.
::dropbox::upload/write-mode("update", "a1c10ce0dd78")
// {".tag": "update", update: "a1c10ce0dd78"}
Types
UploadError
UploadError type {
message: Str,
session-id: Str?,
offset: Int?,
cause: Any
}
A failed upload-session step. message is readable; session-id and
offset say where to continue with resume-upload (null when the
session never started); cause is the underlying HttpError or
transport error.