Repository: kestra-io/kestra
File: core/src/main/java/io/kestra/core/models/tasks/runners/PluginUtilsService.java (Java)

Code before:

                PluginUtilsService.validFilename(finalFileName);

                File file = new File(finalFileName);

                // path with "/", create the subfolders
                if (file.getParent() != null) {
                    Path subFolder = Paths.get(
                        workingDirectory.toAbsolutePath().toString(),
                        new File(finalFileName).getParent()
                    );

                    if (!subFolder.toFile().exists()) {
                        Files.createDirectories(subFolder);
                    }
                }

                String filePath = workingDirectory + "/" + finalFileName;
                String renderedFile;
                if (render) {
                    renderedFile = runContext.render(inputFiles.get(fileName), additionalVars);
                } else {
                    renderedFile = inputFiles.get(fileName);
                }

                if (URIFetcher.supports(renderedFile)) {
                    var uri = URIFetcher.of(renderedFile);
                    try (
                        InputStream inputStream = new BufferedInputStream(uri.fetch(runContext));
                        OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(filePath))
                    ) {
                        int byteRead;
                        while ((byteRead = inputStream.read()) != -1) {
                            outputStream.write(byteRead);
                        }
                        outputStream.flush();
                    }
                } else {
                    try (BufferedWriter writer = new BufferedWriter(new FileWriter(filePath))) {
                        writer.write(renderedFile);
                    }
                }
            }
        }
    }

    /**
     * Create input files with rendered contents.
     */
    public static void createInputFiles(RunContext runContext, Path workingDirectory, Map<String, String> inputFiles, Map<String, Object> additionalVars) throws Exception {
        createInputFilesInternal(runContext, workingDirectory, inputFiles, additionalVars, true);

Review comment (suggestion):
```suggestion
                if (URIFetcher.supports(rFile)) {
```

Code after:
                PluginUtilsService.validFilename(finalFileName);

                File file = new File(finalFileName);

                // path with "/", create the subfolders
                if (file.getParent() != null) {
                    Path subFolder = Paths.get(
                        workingDirectory.toAbsolutePath().toString(),
                        new File(finalFileName).getParent()
                    );

                    if (!subFolder.toFile().exists()) {
                        Files.createDirectories(subFolder);
                    }
                }

                String filePath = workingDirectory + "/" + finalFileName;
                String rFile;
                if (render) {
                    rFile = runContext.render(inputFiles.get(fileName), additionalVars);
                } else {
                    rFile = inputFiles.get(fileName);
                }

                if (URIFetcher.supports(rFile)) {
                    var uri = URIFetcher.of(rFile);
                    try (
                        InputStream inputStream = new BufferedInputStream(uri.fetch(runContext));
                        OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(filePath))
                    ) {
                        int byteRead;
                        while ((byteRead = inputStream.read()) != -1) {
                            outputStream.write(byteRead);
                        }
                        outputStream.flush();
                    }
                } else {
                    try (BufferedWriter writer = new BufferedWriter(new FileWriter(filePath))) {
                        writer.write(rFile);
                    }
                }
            }
        }
    }

    /**
     * Create input files with rendered contents.
     */
    public static void createInputFiles(RunContext runContext, Path workingDirectory, Map<String, String> inputFiles, Map<String, Object> additionalVars) throws Exception {
        createInputFilesInternal(runContext, workingDirectory, inputFiles, additionalVars, true);
    }