Skip to content
Myr

Add multipart docs

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tom Christie · committed by Tom Christie · parent 6a44b05 · Browse files · 3 files+35 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+35 added−2 removed

  • other:+35 added−2 removed

3 files+35 added−2 removed

modified:docs/index.md+1 added-1 removed
modified:docs/quickstart.md+33 added
159 unmodified lines
160 ...161}162```163164## Sending Multipart File Uploads165166You can also upload files, using HTTP multipart encoding:167168```python169>>> files = {'upload-file': open('report.xls', 'rb')}170>>> r = http3.post("https://httpbin.org/post", files=files)171>>> print(r.text)172{173 ...174 "files": {175 "upload-file": "<... binary content ...>"176 },177 ...178}179```180181You can also explicitly set the filename and content type, by using a tuple182of items for the file value:183184```python185>>> files = {'upload-file': ('report.xls', open('report.xls', 'rb'), 'application/vnd.ms-excel')}186>>> r = http3.post("https://httpbin.org/post", files=files)187>>> print(r.text)188{189 ...190 "files": {191 "upload-file": "<... binary content ...>"192 },193 ...194}195```196197## Sending JSON Encoded Data198199Form encoded data is okay if all you need is simple key-value data structure.200For more complicated data structures you'll often want to use JSON encoding instead.
187 unmodified lines
modified:README.md+1 added-1 removed
52 unmodified lines
53* Elegant Key/Value Cookies54* Automatic Decompression55* Automatic Content Decoding56* Unicode Response Bodies57* Multipart File Uploads *TODO*57* Multipart File Uploads58* HTTP(S) Proxy Support *TODO*59* Connection Timeouts60* Streaming Downloads61* .netrc Support *TODO*
40 unmodified lines