@Override protected InputStream wrapObjectStream(File object, InputStream stream) throws IOException { return CompressionUtils.decompress(stream, object.getPath()); }
@Override protected InputStream wrapObjectStream(URI object, InputStream stream) throws IOException { return CompressionUtils.decompress(stream, object.getPath()); }
@Override protected InputStream wrapObjectStream(GoogleBlob object, InputStream stream) throws IOException { return CompressionUtils.decompress(stream, object.getPath()); }
@Override protected InputStream wrapObjectStream(CloudFilesBlob object, InputStream stream) throws IOException { return CompressionUtils.decompress(stream, object.getPath()); }
@Override protected InputStream wrapObjectStream(URI object, InputStream stream) throws IOException { return CompressionUtils.decompress(stream, S3Utils.extractS3Key(object)); }
@Override protected InputStream wrapObjectStream(AzureBlob object, InputStream stream) throws IOException { return CompressionUtils.decompress(stream, object.getPath()); }
@Test public void testDecompressZip() throws IOException { final File tmpDir = temporaryFolder.newFolder("testDecompressZip"); final File zipFile = new File(tmpDir, testFile.getName() + ".zip"); Assert.assertFalse(zipFile.exists()); try (final ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFile))) { out.putNextEntry(new ZipEntry("cool.file")); ByteStreams.copy(new FileInputStream(testFile), out); out.closeEntry(); } try (final InputStream inputStream = CompressionUtils.decompress(new FileInputStream(zipFile), zipFile.getName())) { assertGoodDataStream(inputStream); } }
@Test public void testDecompressBzip2() throws IOException { final File tmpDir = temporaryFolder.newFolder("testDecompressBzip2"); final File bzFile = new File(tmpDir, testFile.getName() + ".bz2"); Assert.assertFalse(bzFile.exists()); try (final OutputStream out = new BZip2CompressorOutputStream(new FileOutputStream(bzFile))) { ByteStreams.copy(new FileInputStream(testFile), out); } try (final InputStream inputStream = CompressionUtils.decompress(new FileInputStream(bzFile), bzFile.getName())) { assertGoodDataStream(inputStream); } }
@Test public void testDecompressXz() throws IOException { final File tmpDir = temporaryFolder.newFolder("testDecompressXz"); final File xzFile = new File(tmpDir, testFile.getName() + ".xz"); Assert.assertFalse(xzFile.exists()); try (final OutputStream out = new XZCompressorOutputStream(new FileOutputStream(xzFile))) { ByteStreams.copy(new FileInputStream(testFile), out); } try (final InputStream inputStream = CompressionUtils.decompress(new FileInputStream(xzFile), xzFile.getName())) { assertGoodDataStream(inputStream); } }
@Test public void testDecompressSnappy() throws IOException { final File tmpDir = temporaryFolder.newFolder("testDecompressSnappy"); final File snappyFile = new File(tmpDir, testFile.getName() + ".sz"); Assert.assertFalse(snappyFile.exists()); try (final OutputStream out = new FramedSnappyCompressorOutputStream(new FileOutputStream(snappyFile))) { ByteStreams.copy(new FileInputStream(testFile), out); } try (final InputStream inputStream = CompressionUtils.decompress(new FileInputStream(snappyFile), snappyFile.getName())) { assertGoodDataStream(inputStream); } }
@Test public void testDecompressZstd() throws IOException { final File tmpDir = temporaryFolder.newFolder("testDecompressZstd"); final File zstdFile = new File(tmpDir, testFile.getName() + ".zst"); Assert.assertFalse(zstdFile.exists()); try (final OutputStream out = new ZstdCompressorOutputStream(new FileOutputStream(zstdFile))) { ByteStreams.copy(new FileInputStream(testFile), out); } try (final InputStream inputStream = CompressionUtils.decompress(new FileInputStream(zstdFile), zstdFile.getName())) { assertGoodDataStream(inputStream); } }
@Test public void testGoodGzipByteSource() throws IOException { final File tmpDir = temporaryFolder.newFolder("testGoodGzipByteSource"); final File gzFile = new File(tmpDir, testFile.getName() + ".gz"); Assert.assertFalse(gzFile.exists()); CompressionUtils.gzip(Files.asByteSource(testFile), Files.asByteSink(gzFile), Predicates.alwaysTrue()); Assert.assertTrue(gzFile.exists()); try (final InputStream inputStream = CompressionUtils.decompress(new FileInputStream(gzFile), gzFile.getName())) { assertGoodDataStream(inputStream); } if (!testFile.delete()) { throw new IOE("Unable to delete file [%s]", testFile.getAbsolutePath()); } Assert.assertFalse(testFile.exists()); CompressionUtils.gunzip(Files.asByteSource(gzFile), testFile); Assert.assertTrue(testFile.exists()); try (final InputStream inputStream = new FileInputStream(testFile)) { assertGoodDataStream(inputStream); } }
CompressionUtils.gzip(Files.asByteSource(testFile), Files.asByteSink(gzFile), Predicates.alwaysTrue()); Assert.assertTrue(gzFile.exists()); try (final InputStream inputStream = CompressionUtils.decompress(new FileInputStream(gzFile), "file.gz")) { assertGoodDataStream(inputStream);
); Assert.assertTrue(gzFile.exists()); try (final InputStream inputStream = CompressionUtils.decompress(new FileInputStream(gzFile), "file.gz")) { assertGoodDataStream(inputStream);
@Override protected InputStream wrapObjectStream(URI object, InputStream stream) throws IOException { return CompressionUtils.decompress(stream, object.getPath()); }
@Override protected InputStream wrapObjectStream(File object, InputStream stream) throws IOException { return CompressionUtils.decompress(stream, object.getPath()); }
@Override protected InputStream wrapObjectStream(URI object, InputStream stream) throws IOException { return CompressionUtils.decompress(stream, S3Utils.extractS3Key(object)); }