74 content_boundary: str,
76 stream: io.BufferedIOBase,
77 file_name: str) ->
None:
79 Given sufficient header data and an input stream, stream raw content to a
80 file, hashing it at the same time to verify the given signature.
83 final_boundary = f
"\r\n--{content_boundary}--\r\n"
84 final_boundary_size = len(final_boundary)
96 remaining_bytes = content_length - final_boundary_size
99 header_bytes = _read_part_headers(stream)
100 remaining_bytes = remaining_bytes - header_bytes
104 digest = _read_to_file(stream, file_name, remaining_bytes)
106 raise Exception(
"invalid part format")
107 if digest != expect_digest:
108 raise Exception(
"digest mismatch")
111 tail = _read_to_memory(stream, final_boundary_size)
112 if tail
is None or tail.decode() != final_boundary:
113 raise Exception(
"invalid part tail")