private void executeCopyAction(DockerClientExecutor dockerClientExecutor, String containerId, Copy configurationParameters) throws IOException { String to = null; String from = null; if (configurationParameters.getTo() != null && configurationParameters.getFrom() != null) { to = configurationParameters.getTo(); from = configurationParameters.getFrom(); } else { throw new IllegalArgumentException( String.format("to and from property is mandatory when copying files from container %s.", containerId)); } InputStream response = dockerClientExecutor.getFileOrDirectoryFromContainerAsTar(containerId, from); Path toPath = Paths.get(to); File toPathFile = toPath.toFile(); if (toPathFile.exists() && toPathFile.isFile()) { throw new IllegalArgumentException(String.format( "%s parameter should be a directory in copy operation but you set an already existing file not a directory. Check %s in your local directory because currently is a file.", "to", toPath.normalize().toString())); } Files.createDirectories(toPath); IOUtil.untar(response, toPathFile); } }
private void executeCopyAction(DockerClientExecutor dockerClientExecutor, String containerId, Copy configurationParameters) throws IOException { String to = null; String from = null; if (configurationParameters.getTo() != null && configurationParameters.getFrom() != null) { to = configurationParameters.getTo(); from = configurationParameters.getFrom(); } else { throw new IllegalArgumentException( String.format("to and from property is mandatory when copying files from container %s.", containerId)); } InputStream response = dockerClientExecutor.getFileOrDirectoryFromContainerAsTar(containerId, from); Path toPath = Paths.get(to); File toPathFile = toPath.toFile(); if (toPathFile.exists() && toPathFile.isFile()) { throw new IllegalArgumentException(String.format( "%s parameter should be a directory in copy operation but you set an already existing file not a directory. Check %s in your local directory because currently is a file.", "to", toPath.normalize().toString())); } Files.createDirectories(toPath); IOUtil.untar(response, toPathFile); } }