From be1e0fa1f20e40eea5f0844145781d285ba70e14 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Sat, 7 Mar 2015 14:38:38 +0100 Subject: [PATCH] Upload IOURC file via the web interface --- gns3server/handlers/upload_handler.py | 10 +++++++--- gns3server/templates/upload.html | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gns3server/handlers/upload_handler.py b/gns3server/handlers/upload_handler.py index 2ca5eb1e..a4a9396e 100644 --- a/gns3server/handlers/upload_handler.py +++ b/gns3server/handlers/upload_handler.py @@ -55,11 +55,15 @@ class UploadHandler: response.redirect("/upload") return - if data["type"] not in ["IOU", "QEMU", "IOS"]: + if data["type"] not in ["IOU", "IOURC", "QEMU", "IOS"]: raise HTTPForbidden("You are not authorized to upload this kind of image {}".format(data["type"])) - destination_dir = os.path.join(UploadHandler.image_directory(), data["type"]) - destination_path = os.path.join(destination_dir, data["file"].filename) + if data["type"] == "IOURC": + destination_dir = os.path.expanduser("~/") + destination_path = os.path.join(destination_dir, ".iourc") + else: + destination_dir = os.path.join(UploadHandler.image_directory(), data["type"]) + destination_path = os.path.join(destination_dir, data["file"].filename) try: os.makedirs(destination_dir, exist_ok=True) with open(destination_path, "wb+") as f: diff --git a/gns3server/templates/upload.html b/gns3server/templates/upload.html index 1b230474..eeeeae55 100644 --- a/gns3server/templates/upload.html +++ b/gns3server/templates/upload.html @@ -5,6 +5,7 @@ File:
Image type: