나는 Turbogears 2.3.3을 사용하는 webapp에서 작업 중입니다.
내 앱에서 사용자는 길 찾기 집합을 얻고 이에 따라 일부 파일을 다운로드해야합니다.
파일 이름을 utf8로 다운로드 할 수 있어야합니다. 나는 그런 파일을 가져하려고 할 때, 파일 이름은 원본 파일의 확장자가 "다운로드" Turbogears 응답 - utf-8 파일 이름 전송
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)
입니다 : 다음은 파일 다운로드를위한 나의 방법이다. 이 코드하려고하면
는 :
response.headerlist.append(('Content-Disposition','attachment;filename=%s'%str(kw['filename'])))
을 kw의 [ '파일 이름'] UTF-8, 내 파일의 대부분이 될 것 인 경우 오류가 발생합니다. 원본 파일 이름이있는 방법이 있습니까?
도움을 주셔서 감사합니다.