Skip to main content

spool_request_stream

Function spool_request_stream 

Source
pub async fn spool_request_stream(
    stream: RequestBodyStream,
    dir: Option<&Path>,
) -> Result<SpooledBody, AwsServiceError>
Expand description

Stream a request body to a tempfile on disk while computing its MD5 and length on the fly. The body is never materialized into a single Bytes buffer; chunks flow from hyper -> Tokio file in constant memory. A 1 GiB PutObject moves through this function with peak resident memory bounded by hyper’s per-frame buffer.

dir controls where the tempfile lands. S3 callers point this at the S3 object root so the eventual rename into the final storage path stays on the same filesystem and is a metadata-only move. Memory-mode callers can pass None for the system temp dir; the memory store reads the file back into bytes and unlinks it.