projects
/
services
/
python-requests.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
6b129ec
)
added support for explicit filenames in `files` parameter.
author
Rolando Espinoza La fuente
<darkrho@gmail.com>
Wed, 16 Nov 2011 04:03:19 +0000
(
00:03
-0400)
committer
Rolando Espinoza La fuente
<darkrho@gmail.com>
Wed, 16 Nov 2011 04:03:19 +0000
(
00:03
-0400)
files = {
"files[]": ("myfile", open("foo")),
}
requests/models.py
patch
|
blob
|
history
diff --git
a/requests/models.py
b/requests/models.py
index
97237e7
..
75b9856
100644
(file)
--- a/
requests/models.py
+++ b/
requests/models.py
@@
-371,7
+371,13
@@
class Request(object):
fields = dict(self.data)
for (k, v) in self.files.items():
- fields.update({k: (guess_filename(k) or k, v.read())})
+ # support for explicit filename
+ if isinstance(v, (tuple, list)):
+ fn, fp = v
+ else:
+ fn = guess_filename(v) or k
+ fp = v
+ fields.update({k: (fn, fp.read())})
(body, content_type) = encode_multipart_formdata(fields)
else: