Search in sources :

Example 71 with TarArchiveOutputStream

use of org.apache.commons.compress.archivers.tar.TarArchiveOutputStream in project neo4j by neo4j.

the class Dumper method openArchiveOut.

private static ArchiveOutputStream openArchiveOut(Path archive) throws IOException {
    // StandardOpenOption.CREATE_NEW is important here because it atomically asserts that the file doesn't
    // exist as it is opened, avoiding a TOCTOU race condition which results in a security vulnerability. I
    // can't see a way to write a test to verify that we are using this option rather than just implementing
    // the check ourselves non-atomically.
    TarArchiveOutputStream tarball = new TarArchiveOutputStream(new GzipCompressorOutputStream(Files.newOutputStream(archive, StandardOpenOption.CREATE_NEW)));
    tarball.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
    tarball.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX);
    return tarball;
}
Also used : GzipCompressorOutputStream(org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream) TarArchiveOutputStream(org.apache.commons.compress.archivers.tar.TarArchiveOutputStream)

Example 72 with TarArchiveOutputStream

use of org.apache.commons.compress.archivers.tar.TarArchiveOutputStream in project tika by apache.

the class TarWriter method writeTo.

public void writeTo(Map<String, byte[]> parts, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {
    TarArchiveOutputStream zip = new TarArchiveOutputStream(entityStream);
    for (Map.Entry<String, byte[]> entry : parts.entrySet()) {
        tarStoreBuffer(zip, entry.getKey(), entry.getValue());
    }
    zip.close();
}
Also used : TarArchiveOutputStream(org.apache.commons.compress.archivers.tar.TarArchiveOutputStream) MultivaluedMap(javax.ws.rs.core.MultivaluedMap) Map(java.util.Map)

Example 73 with TarArchiveOutputStream

use of org.apache.commons.compress.archivers.tar.TarArchiveOutputStream in project gradle by gradle.

the class TarTaskOutputPacker method pack.

@Override
public PackResult pack(SortedSet<ResolvedTaskOutputFilePropertySpec> propertySpecs, Map<String, Map<String, FileContentSnapshot>> outputSnapshots, OutputStream output, TaskOutputOriginWriter writeOrigin) throws IOException {
    BufferedOutputStream bufferedOutput;
    if (output instanceof BufferedOutputStream) {
        bufferedOutput = (BufferedOutputStream) output;
    } else {
        bufferedOutput = new BufferedOutputStream(output);
    }
    TarArchiveOutputStream tarOutput = new TarArchiveOutputStream(bufferedOutput, "utf-8");
    try {
        tarOutput.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
        tarOutput.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX);
        tarOutput.setAddPaxHeadersForNonAsciiNames(true);
        packMetadata(writeOrigin, tarOutput);
        long entryCount = pack(propertySpecs, outputSnapshots, tarOutput);
        return new PackResult(entryCount + 1);
    } finally {
        IOUtils.closeQuietly(tarOutput);
    }
}
Also used : TarArchiveOutputStream(org.apache.commons.compress.archivers.tar.TarArchiveOutputStream) BufferedOutputStream(java.io.BufferedOutputStream)

Example 74 with TarArchiveOutputStream

use of org.apache.commons.compress.archivers.tar.TarArchiveOutputStream in project alluxio by Alluxio.

the class TarUtils method getTarArchiveOutputStream.

private static TarArchiveOutputStream getTarArchiveOutputStream(String path) throws IOException {
    // Generate tar.gz file
    TarArchiveOutputStream taos = new TarArchiveOutputStream(new GzipCompressorOutputStream(new FileOutputStream(path)));
    // TAR has an 8G file limit by default, this gets around that
    taos.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_STAR);
    // TAR originally does not support long file names, enable the support for it
    taos.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
    taos.setAddPaxHeadersForNonAsciiNames(true);
    return taos;
}
Also used : GzipCompressorOutputStream(org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream) FileOutputStream(java.io.FileOutputStream) TarArchiveOutputStream(org.apache.commons.compress.archivers.tar.TarArchiveOutputStream)

Example 75 with TarArchiveOutputStream

use of org.apache.commons.compress.archivers.tar.TarArchiveOutputStream in project zeppelin by apache.

the class TarUtils method getTarArchiveOutputStream.

private static TarArchiveOutputStream getTarArchiveOutputStream(String name) throws IOException {
    FileOutputStream fileOutputStream = new FileOutputStream(name);
    GzipCompressorOutputStream gzipOutputStream = new GzipCompressorOutputStream(fileOutputStream);
    TarArchiveOutputStream taos = new TarArchiveOutputStream(gzipOutputStream);
    // TAR has an 8 gig file limit by default, this gets around that
    taos.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_STAR);
    // TAR originally didn't support long file names, so enable the support for it
    taos.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
    taos.setAddPaxHeadersForNonAsciiNames(true);
    return taos;
}
Also used : GzipCompressorOutputStream(org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream) FileOutputStream(java.io.FileOutputStream) TarArchiveOutputStream(org.apache.commons.compress.archivers.tar.TarArchiveOutputStream)

Aggregations

TarArchiveOutputStream (org.apache.commons.compress.archivers.tar.TarArchiveOutputStream)101 File (java.io.File)42 TarArchiveEntry (org.apache.commons.compress.archivers.tar.TarArchiveEntry)42 FileOutputStream (java.io.FileOutputStream)37 GzipCompressorOutputStream (org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream)30 BufferedOutputStream (java.io.BufferedOutputStream)22 IOException (java.io.IOException)21 ByteArrayOutputStream (java.io.ByteArrayOutputStream)20 FileInputStream (java.io.FileInputStream)19 Path (java.nio.file.Path)17 GZIPOutputStream (java.util.zip.GZIPOutputStream)17 ByteArrayInputStream (java.io.ByteArrayInputStream)15 OutputStream (java.io.OutputStream)13 Test (org.junit.Test)12 ArchiveEntry (org.apache.commons.compress.archivers.ArchiveEntry)11 ArchiveOutputStream (org.apache.commons.compress.archivers.ArchiveOutputStream)11 TarArchiveInputStream (org.apache.commons.compress.archivers.tar.TarArchiveInputStream)9 ZipArchiveOutputStream (org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream)9 ImageArchiveManifest (io.fabric8.maven.docker.model.ImageArchiveManifest)8 InputStream (java.io.InputStream)7