pub(crate) async fn extract_file(
multipart: &mut Multipart,
max_file_size_mb: usize,
) -> Result<Bytes, ApiError>Expand description
Extract file data from multipart request.
Automatically decompresses gzip-compressed files, refusing inputs whose
decompressed size would exceed max_file_size_mb.
Reads the file field one chunk at a time (rather than buffering the
whole field via Field::bytes()) so an oversized upload is caught and
rejected — with a clean FileTooLarge -> 413, logged in
ApiError::into_response — as soon as the running total crosses
max_file_size_mb, instead of only after the entire body has been
received. This also means the raw framework body limit
(DefaultBodyLimit, set well above this ceiling in main.rs) is a
defense-in-depth backstop, not the thing actually enforcing the limit.