Add note on data fields in multipart form encoding (#1022)
* Add note on data fields in multipart form encoding * Fix message
This commit is contained in:
parent
b481166481
commit
0f7d644b8d
@ -463,6 +463,8 @@ MIME header field.
|
||||
!!! tip
|
||||
It is safe to upload large files this way. File uploads are streaming by default, meaning that only one chunk will be loaded into memory at a time.
|
||||
|
||||
Non-file data fields can be included in the multipart form using by passing them to `data=...`.
|
||||
|
||||
## Customizing authentication
|
||||
|
||||
When issuing requests or instantiating a client, the `auth` argument can be used to pass an authentication scheme to use. The `auth` argument may be one of the following...
|
||||
|
||||
@ -191,6 +191,25 @@ of items for the file value:
|
||||
}
|
||||
```
|
||||
|
||||
If you need to include non-file data fields in the multipart form, use the `data=...` parameter:
|
||||
|
||||
```python
|
||||
>>> data = {'message': 'Hello, world!'}
|
||||
>>> files = {'file': open('report.xls', 'rb')}
|
||||
>>> r = httpx.post("https://httpbin.org/post", data=data, files=files)
|
||||
>>> print(r.text)
|
||||
{
|
||||
...
|
||||
"files": {
|
||||
"file": "<... binary content ...>"
|
||||
},
|
||||
"form": {
|
||||
"message": "Hello, world!",
|
||||
},
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
## Sending JSON Encoded Data
|
||||
|
||||
Form encoded data is okay if all you need is a simple key-value data structure.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user