public static String replaceInternalStorage(
        RunContext runContext,
        @Nullable String command,
        boolean replaceWithRelativePath
    ) throws IOException {
        if (command == null) {
            return "";
        }

        return INTERNAL_STORAGE_PATTERN
            .matcher(command)
            .replaceAll(throwFunction(matchResult -> {
                String localFile = saveOnLocalStorage(runContext, matchResult.group()).replace("\\", "/");

                if (!replaceWithRelativePath) {
                    return localFile;
                }

                return runContext.workingDir().path().relativize(Path.of(localFile)).toString();
            }));
    }
@Test
    void uploadInputFiles() throws IOException {
        var runContext = runContextFactory.of();

        Path path = Path.of("/tmp/unittest/file.txt");
        if (!path.toFile().exists()) {
            Files.createFile(path);
        }

        List<File> filesToDelete = new ArrayList<>();
        String internalStorageUri = "kestra://some/file.txt";

        try {
            String wdir = "/my/wd";
            var commands = ScriptService.replaceInternalStorage(
                runContext,
                Map.of("workingDir", wdir),
                List.of(
                    "my command with an internal storage file: " + internalStorageUri,
                    "my command with some additional var usage: {{ workingDir }}"
                ),
                false
            );
            assertThat(commands, not(empty()));

            assertThat(commands.getFirst(), not(is("my command with an internal storage file: " + internalStorageUri)));
            Matcher matcher = COMMAND_PATTERN_CAPTURE_LOCAL_PATH.matcher(commands.getFirst());
            assertThat(matcher.matches(), is(true));
            File file = Path.of(matcher.group(1)).toFile();
            assertThat(file.exists(), is(true));
            filesToDelete.add(file);

            assertThat(commands.get(1), is("my command with some additional var usage: " + wdir));

            commands = ScriptService.replaceInternalStorage(runContext, Collections.emptyMap(), List.of("my command with an internal storage file: " + internalStorageUri), true);
            matcher = COMMAND_PATTERN_CAPTURE_LOCAL_PATH.matcher(commands.getFirst());
            assertThat(matcher.matches(), is(true));
            file = runContext.workingDir().resolve(Path.of(matcher.group(1))).toFile();
            assertThat(file.exists(), is(true));
            filesToDelete.add(file);
        } catch (IllegalVariableEvaluationException e) {
            throw new RuntimeException(e);
        } finally {
            filesToDelete.forEach(File::delete);
            path.toFile().delete();
        }
    }