pub async fn spool_request_stream(
stream: RequestBodyStream,
dir: Option<&Path>,
aws_chunked: bool,
) -> 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.
aws_chunked decodes the Content-Encoding: aws-chunked application-layer
framing that default modern S3 clients apply (see AwsChunkedDecoder), so
the spooled bytes, MD5/ETag, and size reflect the real payload — not the
chunk-size/signature framing. Non-S3 callers (and raw UNSIGNED-PAYLOAD
uploads) pass false and stream verbatim.