fix: read file content into memory before closing file handle in download view (#247)

This commit is contained in:
Vyacheslav Makodin
2026-05-07 05:37:02 +05:00
committed by GitHub
parent 26853a0209
commit 70e091e213
+6 -7
View File
@@ -395,14 +395,13 @@ def check_for_file(request):
def download(request):
filename = request.GET['filename']
uuid = request.GET['uuid']
#filename = filename+".exe"
file_path = os.path.join('exe',uuid,filename)
file_path = os.path.join('exe', uuid, filename)
with open(file_path, 'rb') as file:
response = HttpResponse(file, headers={
'Content-Type': 'application/vnd.microsoft.portable-executable',
'Content-Disposition': f'attachment; filename="{filename}"'
})
content = file.read()
response = HttpResponse(content, headers={
'Content-Type': 'application/vnd.microsoft.portable-executable',
'Content-Disposition': f'attachment; filename="{filename}"'
})
return response
def get_png(request):