use of org.apache.commons.compress.archivers.tar.TarArchiveOutputStream in project testcontainers-java by testcontainers.
the class MountableFileTest method intoTarArchive.
private TarArchiveInputStream intoTarArchive(Consumer<TarArchiveOutputStream> consumer) throws IOException {
@Cleanup final ByteArrayOutputStream baos = new ByteArrayOutputStream();
@Cleanup final TarArchiveOutputStream taos = new TarArchiveOutputStream(baos);
consumer.accept(taos);
taos.close();
return new TarArchiveInputStream(new ByteArrayInputStream(baos.toByteArray()));
}
use of org.apache.commons.compress.archivers.tar.TarArchiveOutputStream in project elastest-torm by elastest.
the class FilesService method getTarArchiveOutputStream.
private TarArchiveOutputStream getTarArchiveOutputStream(String name) throws FileNotFoundException {
logger.info("Creating output for the tar file.");
TarArchiveOutputStream taos = new TarArchiveOutputStream(new FileOutputStream(name));
taos.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_STAR);
taos.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
taos.setAddPaxHeadersForNonAsciiNames(true);
return taos;
}
use of org.apache.commons.compress.archivers.tar.TarArchiveOutputStream in project xp by enonic.
the class AbstractDumpWriter method openTarStream.
private void openTarStream(final PathRef metaPath) {
try {
this.tarOutputStream = new TarArchiveOutputStream(new GZIPOutputStream(openMetaFileStream(metaPath)));
this.tarOutputStream.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
} catch (Exception e) {
throw new RepoDumpException("Could not open meta-file", e);
}
}
use of org.apache.commons.compress.archivers.tar.TarArchiveOutputStream in project byzer-notebook by byzer-org.
the class UploadFileController method download.
@SneakyThrows
@ApiOperation("download file - from mlsql")
@GetMapping("/upload_file")
public void download(HttpServletRequest request, HttpServletResponse response) {
String username = request.getParameter("userName").toLowerCase();
String fileName = request.getParameter("fileName");
String filePath = System.getProperty("NOTEBOOK_HOME") + "/tmp/" + username + "/" + fileName;
File file = new File(filePath);
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + ".tar\"");
try (TarArchiveOutputStream tarOutputStream = new TarArchiveOutputStream(response.getOutputStream())) {
log.info("User: [" + username + "] Downloading File: " + fileName);
tarOutputStream.setBigNumberMode(BIGNUMBER_POSIX);
ArchiveEntry entry = tarOutputStream.createArchiveEntry(file, fileName);
tarOutputStream.putArchiveEntry(entry);
IOUtils.copyLarge(new FileInputStream((file)), tarOutputStream);
tarOutputStream.closeArchiveEntry();
tarOutputStream.flush();
}
}
use of org.apache.commons.compress.archivers.tar.TarArchiveOutputStream in project cloud-pipeline by epam.
the class ScanServiceTest method mockDockerLayer.
private void mockDockerLayer(String s, ScanRequest headTestLayer) throws IOException, URISyntaxException {
try (ByteArrayOutputStream layer = new ByteArrayOutputStream(BUFFER_SIZE);
TarArchiveOutputStream tar = new TarArchiveOutputStream(new GzipCompressorOutputStream(layer))) {
Files.walk(Paths.get(classLoader.getResource(s).toURI())).filter(Files::isRegularFile).forEach(path -> {
File file = path.toFile();
TarArchiveEntry entry = new TarArchiveEntry(file, file.getName());
entry.setSize(file.length());
try {
tar.putArchiveEntry(entry);
tar.write(IOUtils.toByteArray(new FileInputStream(file)));
tar.closeArchiveEntry();
} catch (IOException e) {
e.printStackTrace();
}
});
tar.close();
Mockito.when(registryService.getDockerLayerBlob(headTestLayer.getLayer())).thenReturn(new ByteArrayInputStream(layer.toByteArray()));
}
}
Aggregations