I receive a request from the client to download some file from the server. The filename is in Hebrew.
@bottle.get("/download/<folder_name>/<file_name>")
def download(folder_name, file_name):
file_name = file_name.decode('utf-8')
folder_name = folder_name.decode('utf-8')
if os.path.exists(os.path.join(folder_name, file_name)):
return bottle.static_file(file_name, root=folder_name, download=True)
The last line fails :
return bottle.static_file(file_name, root=folder_name, download=True)
I get an exception :
UnicodeEncodeError: 'ascii' codec can't encode characters in position 22-25: ordinal not in range(128)
I have no idea what am i doing wrong here.
Callstack shows the exception derives from python bottle code:
File "C:\Python27\Lib\site-packages\bottle-0.10.9-py2.7.egg\bottle.py", line 1669, in __setitem__
def __setitem__(self, key, value): self.dict[_hkey(key)] = [str(value)]
Please help.
Regard, Omer.