Multipart reference¶
-
class
aiohttp.
MultipartResponseWrapper
(resp, stream)¶ Wrapper around the
MultipartBodyReader
to take care about underlying connection and close it when it needs in.-
coroutine
next
()¶ Emits next multipart reader object.
-
coroutine
release
()¶ Releases the connection gracefully, reading all the content to the void.
-
coroutine
-
class
aiohttp.
BodyPartReader
(boundary, headers, content)¶ Multipart reader for single body part.
-
coroutine
read
(*, decode=False)¶ Reads body part data.
-
coroutine
read_chunk
(size=chunk_size)¶ Reads body part content chunk of the specified size.
-
coroutine
json
(*, encoding=None)¶ Like
read()
, but assumes that body parts contains JSON data.- Parameters
encoding (str) – Custom JSON encoding. Overrides specified in charset param of
Content-Type
header
-
coroutine
form
(*, encoding=None)¶ Like
read()
, but assumes that body parts contains form urlencoded data.- Parameters
encoding (str) – Custom form encoding. Overrides specified in charset param of
Content-Type
header
-
decode
(data)¶ Decodes data according the specified
Content-Encoding
orContent-Transfer-Encoding
headers value.Supports
gzip
,deflate
andidentity
encodings forContent-Encoding
header.Supports
base64
,quoted-printable
,binary
encodings forContent-Transfer-Encoding
header.- Parameters
data (bytearray) – Data to decode.
- Raises
RuntimeError
- if encoding is unknown.- Return type
-
get_charset
(default=None)¶ Returns charset parameter from
Content-Type
header or default.
-
coroutine
-
class
aiohttp.
MultipartReader
(headers, content)¶ Multipart body reader.
-
classmethod
from_response
(cls, response)¶ Constructs reader instance from HTTP response.
- Parameters
response –
ClientResponse
instance
-
coroutine
next
()¶ Emits the next multipart body part.
-
coroutine
release
()¶ Reads all the body parts to the void till the final boundary.
-
coroutine
fetch_next_part
()¶ Returns the next body part reader.
-
classmethod
-
class
aiohttp.
MultipartWriter
(subtype='mixed', boundary=None, close_boundary=True)¶ Multipart body writer.
boundary
may be an ASCII-only string.-
append
(obj, headers=None)¶ Append an object to writer.
-
append_payload
(payload)¶ Adds a new body part to multipart writer.
-
append_json
(obj, headers=None)¶ Helper to append JSON part.
-
append_form
(obj, headers=None)¶ Helper to append form urlencoded part.
-
size
¶ Size of the payload.
-