Skip to main content

Module upload

Module upload 

Expand description

Chunked uploads for the RPC transport (file/upload/{begin,chunk,commit}).

A payload too large for one NDJSON frame arrives as ordered chunks and is staged in memory until the client commits it. Staged uploads belong to the connection that began them: another connection cannot name them, and they are released when the connection closes. Three bounds keep staging from becoming a memory sink: a per-connection upload count, an idle deadline, and a process-wide byte budget that every staged byte is charged against when the upload begins.

The idle deadline is enforced by the budget as well as by the owning connection. When a reservation does not fit, the budget reclaims every upload idle past the deadline, freeing its bytes and its reservation, even while the connection that began it stays open and silent.

Structs§

BeginRequest
What begin needs to know about an upload, after the dispatcher has resolved the session incarnation and authorized it.
CompletedUpload
A fully received upload, handed to the commit path for persistence.
UploadBudget
A shared ceiling on staged bytes. Space is reserved for an upload’s full declared size when it begins, so chunks never fail for lack of budget halfway through.
UploadStaging
The uploads one connection has begun and not yet committed.
UploadTarget
The exact session incarnation an upload was begun for: the live session by id and generation, the principal that owns it, and the agent it runs. Commit writes only into this incarnation, so a session closed and recreated under the same id, re-owned, or moved to another agent while the upload was staged is refused rather than written into.

Constants§

MAX_UPLOADS_PER_CONNECTION
Uploads one connection may stage at once.
MAX_UPLOAD_FILENAME_BYTES
Longest filename, in bytes, an upload may carry. The name is only a display label (storage is content-addressed); this is the usual limit for one path component.
PROCESS_STAGED_BYTES
Bytes all connections together may hold in staged uploads, counting both the payload and the metadata each upload retains.
UPLOAD_CHUNK_BYTES
Largest decoded chunk accepted per file/upload/chunk. Its base64 form stays well under the local transport’s frame limit.
UPLOAD_IDLE_TIMEOUT
An upload with no begin, chunk, or commit activity for this long is discarded: by its connection the next time that connection touches uploads, or by the budget when another upload needs the space.