encode_multipart
Encode multipart POST data from a dictionary of form values.
The key will be used as the form data name; the value will be transmitted as content. If the value is a file, the contents of the file will be sent as an application/octet-stream; otherwise, str(value) will be sent.
def encode_multipart(
boundary: string,
data: dict
) - > bytes
Encode multipart POST data from a dictionary of form values. The key will be used as the form data name; the value will be transmitted as content. If the value is a file, the contents of the file will be sent as an application/octet-stream; otherwise, str(value) will be sent.
Parameters
| Name | Type | Description |
|---|---|---|
| boundary | string | The unique string used as a delimiter to separate the different parts of the multipart message. |
| data | dict | A dictionary mapping form field names to their values, which can be strings, file-like objects, or iterables of strings and files for multi-valued fields. |
Returns
| Type | Description |
|---|---|
bytes | A byte string containing the formatted multipart/form-data body, with parts separated by the boundary and terminated by the final boundary marker. |