Skip to content
Myr

Added example of how to send multiple files in one request.

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

authored by Martin Jul · committed by Martin Jul · parent 9b41308 · Browse files · 2 files+25 added−0 removed
This commit

State

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

Diff stats

2 files+25 added−0 removed

  • other:+25 added−0 removed

2 files+25 added−0 removed

modified:docs/user/quickstart.rst+24 added
269 unmodified lines
270``requests-toolbelt``. You should read `the toolbelt's documentation271<https://toolbelt.rtfd.org>`_ for more details about how to use it.272273274POST Multiple Multipart-Encoded Files275-------------------------------------276277You can send multiple files in one request. For example, suppose you want to278upload image files to an HTML form with a multiple file field 'images':279280 <input type="file" name="images" multiple="true" required="true"/>281282To do that, just set files to a list of tuples of (form_field_name, file_info):283284 >>> url = 'http://httpbin.org/post'285 >>> multiple_files = [('images', ('foo.png', open('foo.png', 'rb'), 'image/png')),286 ('images', ('bar.png', open('bar.png', 'rb'), 'image/png'))]287 >>> r = requests.post(url, files=multiple_files)288 >>> r.text289 {290 ...291 'files': {'images': 'data:image/png;base64,iVBORw ....'}292 'Content-Type': 'multipart/form-data; boundary=3131623adb2043caaeb5538cc7aa0b3a',293 ...294 }295296297298Response Status Codes299---------------------300301We can check the response status code::
168 unmodified lines
modified:AUTHORS.rst+1 added
152 unmodified lines
153- Erik Wickstrom <erik@erikwickstrom.com> (`@erikwickstrom <https://github.com/erikwickstrom>`_)154- Константин Подшумок (`@podshumok <https://github.com/podshumok>`_)155- Ben Bass (`@codedstructure <https://github.com/codedstructure>`_)156- Jonathan Wong <evolutionace@gmail.com> (`@ContinuousFunction <https://github.com/ContinuousFunction>`_)157- Martin Jul (`@mjul <https://github.com/mjul>`_)