OneDrive / onedrive-sdk-python

OneDrive SDK for Python! https://dev.onedrive.com
MIT License
1.08k stars 189 forks source link

Can't upload file with unicode name #138

Closed Oleksandr-Silin closed 6 years ago

Oleksandr-Silin commented 6 years ago

this code crashes with next exception: Exception has occurred: exceptions.UnicodeEncodeError 'ascii' codec can't encode characters in position 0-8: ordinal not in range(128)

item = client.item(drive='me', id=folder_id)
children = item.children['новыйфайл.txt'] ## will crash on this line
## or
## children = item.children[u'новыйфайл.txt'] 
children.upload(path_to_file)

but same time i can create folders with unicode characters using SDK

Oleksandr-Silin commented 6 years ago

ok, i figure out reason. It happens only if you use python 2.7, for python 3 you don't need to do it. to fix it you need to change next line at request_builder_base.py from

return self._request_url + "/" + url_segment

to

return self._request_url + "/" + url_segment.decode('utf-8')