Fix download filename when it contains spaces
This commit is contained in:
parent
4fa9ab3c6e
commit
d9e5eff23d
|
@ -1467,12 +1467,13 @@ class MasterView(View):
|
||||||
response.content_type = content_type
|
response.content_type = content_type
|
||||||
else:
|
else:
|
||||||
response.content_type = six.binary_type(content_type)
|
response.content_type = six.binary_type(content_type)
|
||||||
if six.PY3:
|
|
||||||
filename = os.path.basename(path)
|
# content-disposition
|
||||||
response.content_disposition = 'attachment; filename={}'.format(filename)
|
filename = os.path.basename(path)
|
||||||
else:
|
if six.PY2:
|
||||||
filename = os.path.basename(path).encode('ascii', 'replace')
|
filename = filename.encode('ascii', 'replace')
|
||||||
response.content_disposition = b'attachment; filename={}'.format(filename)
|
response.content_disposition = str('attachment; filename="{}"'.format(filename))
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def download_content_type(self, path, filename):
|
def download_content_type(self, path, filename):
|
||||||
|
|
Loading…
Reference in a new issue