Closed ttreuthardt closed 10 years ago
Good catch! Requests expects your to pass the filename in a the value (via a tuple), *BUT it will fallback to the key if it cannot guess it from the fileobj: https://github.com/kennethreitz/requests/blob/3443c177a3b8279b6c5b5ce9c1643689d8983521/requests/models.py#L133 which is how the bug got in there in the first place :p
Thanks!
The call client.upload_file('hello.txt', open('/path/to/file/test.txt‘,'rb')) resulted in the file test.txt on box.com.
The multipart message in the post request looked like the following:
--22f4070af4404a26b26e8af463325ac1 Content-Disposition: form-data; name="hello.txt"; filename="test.txt" .... --22f4070af4404a26b26e8af463325ac1--
This could be fixed by changing the files parameter on requests.post to "files={filename: (filename, fileobj)}".