diff --git a/src/web/templates/index.html b/src/web/templates/index.html index 5c097d11..013d73cd 100644 --- a/src/web/templates/index.html +++ b/src/web/templates/index.html @@ -134,6 +134,16 @@ {% if file["name"] in attached_images %}
Attached!
{% else %} + {% if file["name"].lower().endswith(archive_file_suffix) %} +
+ + +
+
+ + +
+ {% else %}
@@ -168,6 +178,7 @@
{% endif %} + {% endif %} {% endif %} @@ -219,7 +230,7 @@
Upload File diff --git a/src/web/web.py b/src/web/web.py index 7d49e030..1686d6b7 100644 --- a/src/web/web.py +++ b/src/web/web.py @@ -108,6 +108,7 @@ def index(): device_types=device_types["device_types"], free_disk=int(disk["free"] / 1024 / 1024), valid_file_suffix=valid_file_suffix, + archive_file_suffix=ARCHIVE_FILE_SUFFIX, removable_device_types=REMOVABLE_DEVICE_TYPES, ) @@ -570,13 +571,10 @@ def upload_file(): return make_response(("Transferred file corrupted!", 500)) else: log.info(f"File {file.filename} has been uploaded successfully") - if filename.lower().endswith(".zip"): - unzip_file(filename) else: log.debug(f"Chunk {current_chunk + 1} of {total_chunks} " f"for file {file.filename} completed.") - return make_response(("File upload successful!", 200)) @@ -636,6 +634,18 @@ def delete(): return redirect(url_for("index")) +@app.route("/files/unzip", methods=["POST"]) +def unzip(): + image = request.form.get("image") + + if unzip_file(image): + flash("Unzipped file " + image) + return redirect(url_for("index")) + else: + flash("Failed to unzip " + image, "error") + return redirect(url_for("index")) + + @app.route("/files/prop", methods=["POST"]) def show_properties(): file_name = request.form.get("image")