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
The following commit(s) were added to refs/heads/main by this push: new 26097e2f436 CAMEL-19929: camel-main - Dev console for upload should support sub folders 26097e2f436 is described below commit 26097e2f43677f7694f96eaede61922b6b4f14d3 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Thu Sep 28 16:45:50 2023 +0200 CAMEL-19929: camel-main - Dev console for upload should support sub folders --- .../component/platform/http/main/MainHttpServer.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 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 e80cf310cc3..6199257a8d1 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.length() > 0) { + if (!sb.isEmpty()) { 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.length() > 0) { + if (!sb.isEmpty()) { String out = sb.toString(); ctx.end(out); } else if (!root.isEmpty()) { @@ -592,18 +592,20 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware, } protected void setupUploadConsole(final String dir) { - final Route upload = router.route("/q/upload/:filename") + final Route upload = router.route("/q/upload/*") .method(HttpMethod.PUT) // need body handler to handle file uploads .handler(BodyHandler.create(true)); - final Route uploadDelete = router.route("/q/upload/:filename"); + final Route uploadDelete = router.route("/q/upload/*"); uploadDelete.method(HttpMethod.DELETE); Handler<RoutingContext> handler = new Handler<RoutingContext>() { @Override public void handle(RoutingContext ctx) { - String name = ctx.pathParam("filename"); + // grab filename which is after /q/upload/ + String name = ctx.request().path(); + name = StringHelper.after(name, "/q/upload/"); if (name == null) { ctx.response().setStatusCode(400); ctx.end(); @@ -642,6 +644,9 @@ 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 {