fix: read file content into memory before closing file handle in download view (#247)
This commit is contained in:
committed by
GitHub
parent
26853a0209
commit
70e091e213
@@ -395,14 +395,13 @@ def check_for_file(request):
|
|||||||
def download(request):
|
def download(request):
|
||||||
filename = request.GET['filename']
|
filename = request.GET['filename']
|
||||||
uuid = request.GET['uuid']
|
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:
|
with open(file_path, 'rb') as file:
|
||||||
response = HttpResponse(file, headers={
|
content = file.read()
|
||||||
'Content-Type': 'application/vnd.microsoft.portable-executable',
|
response = HttpResponse(content, headers={
|
||||||
'Content-Disposition': f'attachment; filename="{filename}"'
|
'Content-Type': 'application/vnd.microsoft.portable-executable',
|
||||||
})
|
'Content-Disposition': f'attachment; filename="{filename}"'
|
||||||
|
})
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def get_png(request):
|
def get_png(request):
|
||||||
|
|||||||
Reference in New Issue
Block a user