You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/09/28 19:42:02 UTC

[camel] 02/02: Revert "CAMEL-19929: camel-main - Dev console for upload should support sub folders"

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit b57a3fc42e9f691c1fca491c654fa03d7740f979
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Sep 28 21:40:01 2023 +0200

    Revert "CAMEL-19929: camel-main - Dev console for upload should support sub folders"
    
    This reverts commit 26097e2f43677f7694f96eaede61922b6b4f14d3.
---
 .../component/platform/http/main/MainHttpServer.java      | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
index 6199257a8d1..e80cf310cc3 100644
--- a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
+++ b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
@@ -532,7 +532,7 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware,
                             }
                         }
                     });
-                    if (!sb.isEmpty()) {
+                    if (sb.length() > 0) {
                         String out = sb.toString();
                         if (html) {
                             ctx.response().putHeader("content-type", "text/html");
@@ -571,7 +571,7 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware,
                             }
                         }
                     });
-                    if (!sb.isEmpty()) {
+                    if (sb.length() > 0) {
                         String out = sb.toString();
                         ctx.end(out);
                     } else if (!root.isEmpty()) {
@@ -592,20 +592,18 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware,
     }
 
     protected void setupUploadConsole(final String dir) {
-        final Route upload = router.route("/q/upload/*")
+        final Route upload = router.route("/q/upload/:filename")
                 .method(HttpMethod.PUT)
                 // need body handler to handle file uploads
                 .handler(BodyHandler.create(true));
 
-        final Route uploadDelete = router.route("/q/upload/*");
+        final Route uploadDelete = router.route("/q/upload/:filename");
         uploadDelete.method(HttpMethod.DELETE);
 
         Handler<RoutingContext> handler = new Handler<RoutingContext>() {
             @Override
             public void handle(RoutingContext ctx) {
-                // grab filename which is after /q/upload/
-                String name = ctx.request().path();
-                name = StringHelper.after(name, "/q/upload/");
+                String name = ctx.pathParam("filename");
                 if (name == null) {
                     ctx.response().setStatusCode(400);
                     ctx.end();
@@ -644,9 +642,6 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware,
                     boolean exists = f.isFile() && f.exists();
                     LOG.info("{} file: {}/{}", exists ? "Updating" : "Creating", dir, name);
 
-                    // if it has sub folders, then make sure folders exists
-                    f.mkdirs();
-
                     File tmp = new File(dir, name + ".tmp");
                     FileOutputStream fos = null;
                     try {