{"action":"created","issue":{"url":"https://api.github.com/repos/kennethreitz/requests/issues/3446","repository_url":"https://api.github.com/repos/kennethreitz/requests","labels_url":"https://api.github.com/repos/kennethreitz/requests/issues/3446/labels{/name}","comments_url":"https://api.github.com/repos/kennethreitz/requests/issues/3446/comments","events_url":"https://api.github.com/repos/kennethreitz/requests/issues/3446/events","html_url":"https://github.com/kennethreitz/requests/issues/3446","id":167840304,"number":3446,"title":"Posting a mutlipart-encoded file with non-ASCII characters in filename doesn't work","user":{"login":"dtluna","id":10116666,"avatar_url":"https://avatars.githubusercontent.com/u/10116666?v=3","gravatar_id":"","url":"https://api.github.com/users/dtluna","html_url":"https://github.com/dtluna","followers_url":"https://api.github.com/users/dtluna/followers","following_url":"https://api.github.com/users/dtluna/following{/other_user}","gists_url":"https://api.github.com/users/dtluna/gists{/gist_id}","starred_url":"https://api.github.com/users/dtluna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dtluna/subscriptions","organizations_url":"https://api.github.com/users/dtluna/orgs","repos_url":"https://api.github.com/users/dtluna/repos","events_url":"https://api.github.com/users/dtluna/events{/privacy}","received_events_url":"https://api.github.com/users/dtluna/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-07-27T12:21:19Z","updated_at":"2016-07-27T12:44:06Z","closed_at":null,"body":"The following code doesn't actually upload any data to the server:\r\n```python\r\nr = requests.post('https://gs.smuglo.li/api/statusnet/media/upload',\r\n    auth=('testbot', 'testbot'),\r\n    files={'media': open('/tmp/Снимок экрана_2016-07-27_05-15-38.png', 'rb')})\r\n```"},"comment":{"url":"https://api.github.com/repos/kennethreitz/requests/issues/comments/235573503","html_url":"https://github.com/kennethreitz/requests/issues/3446#issuecomment-235573503","issue_url":"https://api.github.com/repos/kennethreitz/requests/issues/3446","id":235573503,"user":{"login":"dtluna","id":10116666,"avatar_url":"https://avatars.githubusercontent.com/u/10116666?v=3","gravatar_id":"","url":"https://api.github.com/users/dtluna","html_url":"https://github.com/dtluna","followers_url":"https://api.github.com/users/dtluna/followers","following_url":"https://api.github.com/users/dtluna/following{/other_user}","gists_url":"https://api.github.com/users/dtluna/gists{/gist_id}","starred_url":"https://api.github.com/users/dtluna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dtluna/subscriptions","organizations_url":"https://api.github.com/users/dtluna/orgs","repos_url":"https://api.github.com/users/dtluna/repos","events_url":"https://api.github.com/users/dtluna/events{/privacy}","received_events_url":"https://api.github.com/users/dtluna/received_events","type":"User","site_admin":false},"created_at":"2016-07-27T12:44:06Z","updated_at":"2016-07-27T12:44:06Z","body":"@Lukasa Sure\r\n```python\r\n>>> filename = '/tmp/Снимок экрана_2016-07-27_05-15-38.png' \r\n>>> media = {'media':(filename.encode('utf-8'), open(filename, 'rb'))}\r\n>>> r = requests.post(url, auth=('testbot', 'testbot'), files=media)\r\nTraceback (most recent call last):\r\n  File \"<input>\", line 1, in <module>\r\n    r = requests.post(url, auth=(username, password), files=media)\r\n  File \"/usr/lib/python3.5/site-packages/requests/api.py\", line 111, in post\r\n    return request('post', url, data=data, json=json, **kwargs)\r\n  File \"/usr/lib/python3.5/site-packages/requests/api.py\", line 57, in request\r\n    return session.request(method=method, url=url, **kwargs)\r\n  File \"/usr/lib/python3.5/site-packages/requests/sessions.py\", line 461, in request\r\n    prep = self.prepare_request(req)\r\n  File \"/usr/lib/python3.5/site-packages/requests/sessions.py\", line 394, in prepare_request\r\n    hooks=merge_hooks(request.hooks, self.hooks),\r\n  File \"/usr/lib/python3.5/site-packages/requests/models.py\", line 298, in prepare\r\n    self.prepare_body(data, files, json)\r\n  File \"/usr/lib/python3.5/site-packages/requests/models.py\", line 449, in prepare_body\r\n    (body, content_type) = self._encode_files(files, data)\r\n  File \"/usr/lib/python3.5/site-packages/requests/models.py\", line 155, in _encode_files\r\n    rf.make_multipart(content_type=ft)\r\n  File \"/usr/lib/python3.5/site-packages/urllib3/fields.py\", line 174, in make_multipart\r\n    (('name', self._name), ('filename', self._filename))\r\n  File \"/usr/lib/python3.5/site-packages/urllib3/fields.py\", line 134, in _render_parts\r\n    parts.append(self._render_part(name, value))\r\n  File \"/usr/lib/python3.5/site-packages/urllib3/fields.py\", line 114, in _render_part\r\n    return format_header_param(name, value)\r\n  File \"/usr/lib/python3.5/site-packages/urllib3/fields.py\", line 35, in format_header_param\r\n    if not any(ch in value for ch in '\"\\\\\\r\\n'):\r\n  File \"/usr/lib/python3.5/site-packages/urllib3/fields.py\", line 35, in <genexpr>\r\n    if not any(ch in value for ch in '\"\\\\\\r\\n'):\r\nTypeError: a bytes-like object is required, not 'str'\r\n```"}}
{"actor":{"display_login":"dtluna"}}