summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Jul <martin@mjul.com>2014-09-16 11:54:31 +0200
committerMartin Jul <martin@mjul.com>2014-09-16 11:54:31 +0200
commit0924069b689c7323f47444b6a19bc037c43b49e2 (patch)
tree3c406d95a97c56846045c494a2525c7d4e61648c
parent4707d11004a201a89257fa3ab5365fb3dc9d2f90 (diff)
downloadpython-requests-0924069b689c7323f47444b6a19bc037c43b49e2.tar.gz
Moved multiple files upload example to advanced section.
-rw-r--r--docs/user/advanced.rst24
-rw-r--r--docs/user/quickstart.rst25
2 files changed, 26 insertions, 23 deletions
diff --git a/docs/user/advanced.rst b/docs/user/advanced.rst
index d285c181..b5758369 100644
--- a/docs/user/advanced.rst
+++ b/docs/user/advanced.rst
@@ -267,6 +267,30 @@ a length) for your body::
requests.post('http://some.url/chunked', data=gen())
+
+POST Multiple Multipart-Encoded Files
+-------------------------------------
+
+You can send multiple files in one request. For example, suppose you want to
+upload image files to an HTML form with a multiple file field 'images':
+
+ <input type="file" name="images" multiple="true" required="true"/>
+
+To do that, just set files to a list of tuples of (form_field_name, file_info):
+
+ >>> url = 'http://httpbin.org/post'
+ >>> multiple_files = [('images', ('foo.png', open('foo.png', 'rb'), 'image/png')),
+ ('images', ('bar.png', open('bar.png', 'rb'), 'image/png'))]
+ >>> r = requests.post(url, files=multiple_files)
+ >>> r.text
+ {
+ ...
+ 'files': {'images': 'data:image/png;base64,iVBORw ....'}
+ 'Content-Type': 'multipart/form-data; boundary=3131623adb2043caaeb5538cc7aa0b3a',
+ ...
+ }
+
+
Event Hooks
-----------
diff --git a/docs/user/quickstart.rst b/docs/user/quickstart.rst
index 4c8a006b..9d4e6904 100644
--- a/docs/user/quickstart.rst
+++ b/docs/user/quickstart.rst
@@ -270,29 +270,8 @@ support this, but there is a separate package which does -
``requests-toolbelt``. You should read `the toolbelt's documentation
<https://toolbelt.rtfd.org>`_ for more details about how to use it.
-
-POST Multiple Multipart-Encoded Files
--------------------------------------
-
-You can send multiple files in one request. For example, suppose you want to
-upload image files to an HTML form with a multiple file field 'images':
-
- <input type="file" name="images" multiple="true" required="true"/>
-
-To do that, just set files to a list of tuples of (form_field_name, file_info):
-
- >>> url = 'http://httpbin.org/post'
- >>> multiple_files = [('images', ('foo.png', open('foo.png', 'rb'), 'image/png')),
- ('images', ('bar.png', open('bar.png', 'rb'), 'image/png'))]
- >>> r = requests.post(url, files=multiple_files)
- >>> r.text
- {
- ...
- 'files': {'images': 'data:image/png;base64,iVBORw ....'}
- 'Content-Type': 'multipart/form-data; boundary=3131623adb2043caaeb5538cc7aa0b3a',
- ...
- }
-
+For sending multiple files in one request refer to the :ref:`advanced <advanced>`
+section.
Response Status Codes