@Override
    public Integer call() throws Exception {
        super.call();
        to = to.startsWith("/") ? to : "/" + to;
        to = to.endsWith("/") ? to : to + "/";

        try (var files = Files.walk(from); DefaultHttpClient client = client()) {
            if (delete) {
                client.toBlocking().exchange(this.requestOptions(HttpRequest.DELETE(apiUri("/namespaces/") + namespace + "/files?path=" + to, null)));
            }

            KestraIgnore kestraIgnore = new KestraIgnore(from);

            List<Path> paths = files
                .filter(Files::isRegularFile)
                .filter(path -> !kestraIgnore.isIgnoredFile(path.toString(), true))
                .toList();
            paths.forEach(path -> {
                MultipartBody body = MultipartBody.builder()
                    .addPart("fileContent", path.toFile())
                    .build();
                String relativizedPath = from.relativize(path).toString();
                String destination = to + relativizedPath;
                client.toBlocking().exchange(
                    this.requestOptions(
                        HttpRequest.POST(
                            apiUri("/namespaces/") + namespace + "/files?path=" + destination,
                            body
                        ).contentType(MediaType.MULTIPART_FORM_DATA)
                    )
                );
                stdOut("Successfully uploaded {0} to {1}", path.toString(), destination);
            });
        } catch (HttpClientResponseException e) {
            AbstractValidateCommand.handleHttpException(e, "namespace");
            return 1;
        }

        return 0;
    }
@Test
    void runWithToSpecified() {
        URL directory = NamespaceFilesUpdateCommandTest.class.getClassLoader().getResource("namespacefiles/noignore");
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        System.setOut(new PrintStream(out));

        try (ApplicationContext ctx = ApplicationContext.run(Environment.CLI, Environment.TEST)) {

            EmbeddedServer embeddedServer = ctx.getBean(EmbeddedServer.class);
            embeddedServer.start();

            String to = "/some/directory";
            String[] args = {
                "--server",
                embeddedServer.getURL().toString(),
                "--user",
                "myuser:pass:word",
                "--delete",
                "io.kestra.cli",
                directory.getPath(),
                to
            };
            PicocliRunner.call(NamespaceFilesUpdateCommand.class, ctx, args);

            assertTransferMessage(out, "2", to);
            assertTransferMessage(out, "1", to);
            assertTransferMessage(out, "flows/flow.yml", to);
            out.reset();
        }
    }