Multipart parser

BáiZé provides a “bring your own I/O” multipart parser with excellent performance.

Shortcut functions

parse_stream

baize.multipart_helper.parse_stream(stream: Iterable[bytes], boundary: bytes, charset: str, *, file_factory: Type[_UploadFile] = <class 'baize.datastructures.UploadFile'>)List[Tuple[str, Union[str, _UploadFile]]]

Parse a synchronous stream in multipart format

for field_name, field_or_file in parse_stream(stream, boundary, charset):
    print(field_name, field_or_file)

parse_async_stream

async baize.multipart_helper.parse_async_stream(stream: AsyncIterable[bytes], boundary: bytes, charset: str, *, file_factory: Type[_UploadFile] = <class 'baize.datastructures.UploadFile'>)List[Tuple[str, Union[str, _UploadFile]]]

Parse an asynchronous stream in multipart format

for field_name, field_or_file in await parse_async_stream(stream, boundary, charset):
    print(field_name, field_or_file)