Fix error 500 on non-ASCII attachment file names

This commit is contained in:
Raphael Michel
2021-11-09 11:54:44 +01:00
parent b0ae40c264
commit dd0a4df914
3 changed files with 3 additions and 3 deletions

View File

@@ -47,7 +47,7 @@ class DownloadView(TemplateView):
return HttpResponse('1' if self.object.file else '0')
elif self.object.file:
resp = ChunkBasedFileResponse(self.object.file.file, content_type=self.object.type)
resp['Content-Disposition'] = 'attachment; filename="{}"'.format(self.object.filename)
resp['Content-Disposition'] = 'attachment; filename="{}"'.format(self.object.filename).encode('ascii', 'ignore')
return resp
else:
return super().get(request, *args, **kwargs)