From 8823dfba7deb52e376b30aae66a8b077c4c443d1 Mon Sep 17 00:00:00 2001 From: Daniel Markstedt Date: Thu, 26 Jan 2023 18:10:33 -0800 Subject: [PATCH] Web UI: Better handling of upload destination dir checks (#1076) Web UI: Better handling of upload destination dir checks --- python/web/src/web.py | 9 ++++++--- python/web/tests/api/test_files.py | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/python/web/src/web.py b/python/web/src/web.py index 646f3dc9..d87d8dd6 100644 --- a/python/web/src/web.py +++ b/python/web/src/web.py @@ -980,11 +980,14 @@ def upload_file(): return make_response(auth["msg"], 403) destination = request.form.get("destination") - if destination == "file_server": - destination_dir = FILE_SERVER_DIR - else: + if destination == "disk_images": server_info = piscsi_cmd.get_server_info() destination_dir = server_info["image_dir"] + elif destination == "shared_files": + destination_dir = FILE_SERVER_DIR + else: + return make_response(f"Invalid destination '{destination}'", 403) + return upload_with_dropzonejs(destination_dir) diff --git a/python/web/tests/api/test_files.py b/python/web/tests/api/test_files.py index fdb15243..af75a2c3 100644 --- a/python/web/tests/api/test_files.py +++ b/python/web/tests/api/test_files.py @@ -253,6 +253,7 @@ def test_upload_file(http_client, delete_file): chunk_byte_offset = chunk_number * chunk_size form_data = { + "destination": "disk_images", "dzuuid": str(uuid.uuid4()), "dzchunkindex": chunk_number, "dzchunksize": chunk_size,