From: barberj Date: Wed, 25 Apr 2012 20:45:21 +0000 (-0400) Subject: sending strings to be received as files X-Git-Tag: v0.12.1~2^2^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e912a6f5da30e9a5507fd14cb6cb32f7e05611c0;p=services%2Fpython-requests.git sending strings to be received as files --- diff --git a/docs/user/quickstart.rst b/docs/user/quickstart.rst index 6231630..bdb6635 100644 --- a/docs/user/quickstart.rst +++ b/docs/user/quickstart.rst @@ -222,6 +222,34 @@ Setting filename explicitly:: "data": "" } +Sending strings to be received as files:: + + >>> url = 'http://httpbin.org/post' + >>> files = {'file': ('report.csv', 'some,data,to,send\nanother,row,to,send\n')} + + >>> r = requests.post(url, files=files) + >>> r.text + { + "origin": "179.13.100.4", + "files": { + "file": "some,data,to,send\\nanother,row,to,send\\n" + }, + "form": {}, + "url": "http://httpbin.org/post", + "args": {}, + "headers": { + "Content-Length": "216", + "Accept-Encoding": "identity, deflate, compress, gzip", + "Connection": "keep-alive", + "Accept": "*/*", + "User-Agent": "python-requests/0.11.1", + "Host": "httpbin.org", + "Content-Type": "multipart/form-data; boundary=127.0.0.1.502.41433.1335385481.788.1" + }, + "json": null, + "data": "" + } + Response Status Codes ---------------------