# HG changeset patch # User Thierry Florac # Date 1550479884 -3600 # Node ID e17580995a0df68c127be293a9ea5d3dfc329cd1 # Parent ad9ed1e729e09e1a86fb91ec0a6f3b17460ff12c Translate content disposition "filename" attribute when downloading file diff -r ad9ed1e729e0 -r e17580995a0d src/pyams_file/views/file.py --- a/src/pyams_file/views/file.py Thu Feb 14 17:37:44 2019 +0100 +++ b/src/pyams_file/views/file.py Mon Feb 18 09:51:24 2019 +0100 @@ -12,17 +12,14 @@ __docformat__ = 'restructuredtext' - -# import standard library from http.client import NOT_MODIFIED, PARTIAL_CONTENT -# import interfaces -from pyams_file.interfaces import IFile +from pyramid.response import Response +from pyramid.view import view_config from zope.dublincore.interfaces import IZopeDublinCore -# import packages -from pyramid.response import Response -from pyramid.view import view_config +from pyams_file.interfaces import IFile +from pyams_utils.unicode import translate_string MAX_RANGE_LENGTH = 1 << 21 # 2 Mb @@ -50,7 +47,8 @@ body_file = context.get_blob(mode='c') if request.params.get('download') is not None: - response.content_disposition = 'attachment; filename="{0}"'.format(context.filename) + response.content_disposition = 'attachment; filename="{0}"'.format(translate_string(context.filename, + force_lower=False)) # check for range request if request.range is not None: