I'm working on a webapp using Turbogears 2.3.3
In my app the users will get a set of directions and they will need to download some files accordingly.
It is important that they will be able to download the files with their original name, which will be in utf8.
Here is my method for downloading the files:
import os
from webob.static import FileApp
from tg import expose, request, use_wsgi_app, response
....
@expose()
def download(self,**kw):
response.headerlist.append(('Content-Disposition','attachment'))
path_to_file = os.path.join(os.path.dirname(dfuswebapp.__file__), 'PrintFiles')
file_with_path = os.path.join(path_to_file,kw['filename'])
file = FileApp(file_with_path)
return use_wsgi_app(file)
When I Try to get a file like that, the file name is "download" with the extension of the original file.
If I try this code:
response.headerlist.append(('Content-Disposition','attachment;filename=%s'%str(kw['filename'])))
I get an error if kw['filename'] is in utf-8, which most of my files will be.
Is there a way have the original file names?
Thanks for the help