Skip to main content

upload_blob

Function upload_blob 

Source
pub async fn upload_blob(
    __arg0: State<AppState>,
    headers: HeaderMap,
    body: Body,
) -> Response
Expand description

POST /xrpc/com.atproto.repo.uploadBlob

The body is streamed into the store frame by frame and never assembled. The blob’s content identifier is the hash of the bytes, so it does not exist until the last frame has arrived; until then the upload is somewhere no reader can reach, and it becomes a blob in one step at the end. A request that stops half way — a client that disconnects, a body over the size limit — leaves nothing at all, because the store’s upload handle cleans up after itself when it is dropped without being committed.

An app’s OAuth token uploads under a blob: scope, which names the types it may upload. The declared type is checked against it before the body is read, and the type the bytes are filed under is checked again before the blob is kept. The account’s own agent token is not scoped. How large a blob may be is nobody’s grant: the store’s own limit bounds the body as it arrives, and a policy judges the declared length before the body, again at checkpoints while it arrives, and the size that came in once it is in. A body whose length differs from its Content-Length is refused.

The blob reference in the response names the type the bytes carry a signature for wherever that contradicts the Content-Type the request declared, which is one of the two answers atproto’s blob specification allows. A client writes that reference into its record, so the record and what getBlob answers say the same thing.