@Override protected InputStream execute(CopyFileFromContainerCmd command) { WebTarget webResource = getBaseResource().path("/containers/{id}/copy").resolveTemplate("id", command.getContainerId()); LOGGER.trace("POST: " + webResource.toString()); Response response = webResource.request().accept(MediaType.APPLICATION_OCTET_STREAM_TYPE) .post(entity(command, MediaType.APPLICATION_JSON)); return new WrappedResponseInputStream(response); }
try { InputStream is = docker.copyFileFromContainerCmd(container.getId(), resource).withHostPath(hostpath).exec(); final TarArchiveInputStream tais = (TarArchiveInputStream) new ArchiveStreamFactory().createArchiveInputStream("tar", is); File targetPath = new File(hostpath); // hostpath could be a file or a directory
public InputStream getFileOrDirectoryFromContainerAsTar(String containerId, String from) { this.readWriteLock.readLock().lock(); try { InputStream response = dockerClient.copyFileFromContainerCmd(containerId, from).exec(); return response; } finally { this.readWriteLock.readLock().unlock(); } }
/** * Produces a copy file/folder from container request * * @param client * @param message * @return */ private CopyFileFromContainerCmd executeCopyFileContainerRequest(DockerClient client, Message message) { LOGGER.debug("Executing Docker Copy File/Folder Container Request"); String containerId = DockerHelper.getProperty(DockerConstants.DOCKER_CONTAINER_ID, configuration, message, String.class); String resource = DockerHelper.getProperty(DockerConstants.DOCKER_RESOURCE, configuration, message, String.class); if (containerId == null || resource == null) { throw new IllegalArgumentException("Container ID and Resource must be specified"); } CopyFileFromContainerCmd copyFileContainerCmd = client.copyFileFromContainerCmd(containerId, resource); String hostPath = DockerHelper.getProperty(DockerConstants.DOCKER_HOST_PATH, configuration, message, String.class); if (hostPath != null) { copyFileContainerCmd.withHostPath(hostPath); } return copyFileContainerCmd; }
public InputStream getFileOrDirectoryFromContainerAsTar(String containerId, String from) { this.readWriteLock.readLock().lock(); try { InputStream response = dockerClient.copyFileFromContainerCmd(containerId, from).exec(); return response; } finally { this.readWriteLock.readLock().unlock(); } }
break; case COPY_FILE_CONTAINER: result = executeCopyFileContainerRequest(client, message).exec(); break; case CREATE_CONTAINER:
@Override protected InputStream execute(CopyFileFromContainerCmd command) { WebTarget webResource = getBaseResource().path("/containers/{id}/copy").resolveTemplate("id", command.getContainerId()); LOGGER.trace("POST: " + webResource.toString()); return webResource.request().accept(MediaType.APPLICATION_OCTET_STREAM) .post(command); }
@Override protected InputStream execute(CopyFileFromContainerCmd command) { WebTarget webResource = getBaseResource().path("/containers/{id}/copy").resolveTemplate("id", command.getContainerId()); LOGGER.trace("POST: " + webResource.toString()); Response response = webResource.request().accept(MediaType.APPLICATION_OCTET_STREAM_TYPE) .post(entity(command, MediaType.APPLICATION_JSON)); return new WrappedResponseInputStream(response); }
@Override protected InputStream execute(CopyFileFromContainerCmd command) { WebTarget webResource = getBaseResource().path("/containers/{id}/copy").resolveTemplate("id", command.getContainerId()); LOGGER.trace("POST: " + webResource.toString()); return webResource.request().accept(MediaType.APPLICATION_OCTET_STREAM) .post(command); }