Skip to main content

append_chunk

Function append_chunk 

Source
pub async fn append_chunk(
    __arg0: State<AppState>,
    __arg1: Path<String>,
    headers: HeaderMap,
    body: Bytes,
) -> Response
Expand description

PATCH /api/v1/fs/uploads/{id} — append one chunk.

The offset comes from Content-Range rather than the body, so a chunk that arrives twice is refused by position instead of being appended again.

Writing the chunk to the staging file (UploadStore::append) is blocking disk I/O — spawn_blocking, same convention as the other routes here. The route this handler serves also carries DefaultBodyLimit::max(MAX_CHUNK_SIZE) (src/api/router.rs), raising axum-core’s own 2 MiB default so a chunk at the advertised chunk_size (4 MiB) reaches this handler at all, rather than being cut off by axum before append’s own TooLarge check ever runs.