peyk.transport.multipart¶
Helpers for building multipart/form-data bodies.
Thin wrapper around aiohttp.FormData so callers pass a plain mapping of string fields and FilePayload`s instead of learning `FormData’s API directly. File content can be raw bytes or a file-like/stream object (anything aiohttp’s multipart writer accepts) — streams are handed to aiohttp as-is rather than read fully into memory here, so a future adapter can upload a large file without buffering the whole thing.
Functions
|
Performs the build multipart body operation for the transport client. |
Classes
|
A single file part for a multipart request. |
- class peyk.transport.multipart.FilePayload(content: bytes | IO[bytes], filename: str, content_type: str = 'application/octet-stream')[source]¶
Bases:
objectA single file part for a multipart request.
- Variables:
content (bytes | IO[bytes]) – Raw bytes, or a file-like/stream object opened in binary mode. Streams are not read here — they’re passed through to aiohttp’s multipart writer, which reads them in chunks while sending.
filename (str) – Filename reported in the part’s Content-Disposition.
content_type (str) – The part’s Content-Type. Defaults to application/octet-stream.
- content: bytes | IO[bytes]¶
- filename: str¶
- content_type: str = 'application/octet-stream'¶
- peyk.transport.multipart.build_multipart_body(fields: Mapping[str, str] | None = None, files: Mapping[str, FilePayload] | None = None) FormData[source]¶
Performs the build multipart body operation for the transport client.
- Parameters:
fields – Value used by this operation.
files – Value used by this operation.
- Returns:
Result produced by the transport operation.