mirror of
https://github.com/retspen/webvirtcloud
synced 2025-01-12 08:25:18 +00:00
fix upload iso method
This commit is contained in:
parent
a33283e172
commit
62d4cf88ba
1 changed files with 8 additions and 6 deletions
|
@ -91,14 +91,16 @@ def storage(request, compute_id, pool):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def handle_uploaded_file(path, f_name):
|
def handle_uploaded_file(path, f_name):
|
||||||
target = os.path.normpath(os.path.join(path, f_name))
|
target = os.path.normpath(os.path.join(path, str(f_name)))
|
||||||
if not target.startswith(path):
|
if not target.startswith(path):
|
||||||
raise Exception("Security Issues with file uploading")
|
raise Exception(_("Security Issues with file uploading"))
|
||||||
|
|
||||||
destination = open(target, "wb+")
|
try:
|
||||||
for chunk in f_name.chunks():
|
with open(target, "wb+") as f:
|
||||||
destination.write(chunk)
|
for chunk in f_name.chunks():
|
||||||
destination.close()
|
f.write(chunk)
|
||||||
|
except FileNotFoundError:
|
||||||
|
messages.error(request, _("File not found. Check the path variable and filename"))
|
||||||
|
|
||||||
compute = get_object_or_404(Compute, pk=compute_id)
|
compute = get_object_or_404(Compute, pk=compute_id)
|
||||||
meta_prealloc = False
|
meta_prealloc = False
|
||||||
|
|
Loading…
Reference in a new issue