Multipart reference¶
- class aiohttp.MultipartResponseWrapper(resp, stream)¶
Wrapper around the
MultipartReader
to take care about underlying connection and close it when it needs in.- at_eof()¶
Returns
True
when all response data had been read.- Return type
bool
- class aiohttp.BodyPartReader(boundary, headers, content)¶
Multipart reader for single body part.
- at_eof()¶
Returns
True
if the boundary was reached orFalse
otherwise.- Return type
bool
- 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
bytes
- get_charset(default=None)¶
Returns charset parameter from
Content-Type
header or default.
- name¶
A field name specified in
Content-Disposition
header orNone
if missed or header is malformed.Readonly
str
property.
- filename¶
A field filename specified in
Content-Disposition
header orNone
if missed or header is malformed.Readonly
str
property.
- class aiohttp.MultipartReader(headers, content)¶
Multipart body reader.
- classmethod from_response(cls, response)¶
Constructs reader instance from HTTP response.
- Parameters
response –
ClientResponse
instance
- at_eof()¶
Returns
True
if the final boundary was reached orFalse
otherwise.- Return type
bool
- class aiohttp.MultipartWriter(subtype='mixed', boundary=None, close_boundary=True)¶
Multipart body writer.
boundary
may be an ASCII-only string.- boundary¶
The string (
str
) representation of the boundary.Changed in version 3.0: Property type was changed from
bytes
tostr
.
- 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.