blob: d57803659d07bb1d5dc424b7ecf01e2b1bf931e2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
from pathlib import Path
from django.http import FileResponse
def template_bad_filename(request):
content = Path(__file__).parent / "custom_templates" / "project_template.tgz"
f = open(content, "rb")
filename = "/nonexistent/archive.tgz"
response = FileResponse(
f,
as_attachment=True,
filename=filename,
)
# Force the filename to have a slash at the beginning.
response["Content-Disposition"] = f'attachment; filename="{filename}"'
return response
|