Fix download filename when it contains spaces

This commit is contained in:
Lance Edgar 2018-11-25 17:27:31 -06:00
parent 4fa9ab3c6e
commit d9e5eff23d

View file

@ -1467,12 +1467,13 @@ class MasterView(View):
response.content_type = content_type
else:
response.content_type = six.binary_type(content_type)
if six.PY3:
# content-disposition
filename = os.path.basename(path)
response.content_disposition = 'attachment; filename={}'.format(filename)
else:
filename = os.path.basename(path).encode('ascii', 'replace')
response.content_disposition = b'attachment; filename={}'.format(filename)
if six.PY2:
filename = filename.encode('ascii', 'replace')
response.content_disposition = str('attachment; filename="{}"'.format(filename))
return response
def download_content_type(self, path, filename):