You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tika.apache.org by "Pavel Micka (JIRA)" <ji...@apache.org> on 2015/05/22 14:25:17 UTC
[jira] [Comment Edited] (TIKA-1632) ZLIB magic detection support
[ https://issues.apache.org/jira/browse/TIKA-1632?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14556048#comment-14556048 ]
Pavel Micka edited comment on TIKA-1632 at 5/22/15 12:25 PM:
-------------------------------------------------------------
7801f3c92f4acd55c82c282ecd05001907044e - BEST_COMPRESSION
789cf3c92f4acd55c82c282ecd05001907044e - BEST_SPEED
78daf3c92f4acd55c82c282ecd05001907044e -DEFAULT_COMPRESSION
<pre>
import java.util.zip.Deflater;
import java.util.zip.DeflaterInputStream;
private void compressAndVerify(int level) throws IOException {
Deflater deflater = new Deflater(level);
DeflaterInputStream deflaterInputStream = new DeflaterInputStream(new ByteArrayInputStream("Lorem ipsum".getBytes(Constants.internalEncoding)), deflater);
byte[] source = IOUtils.toByteArray(deflaterInputStream);
System.out.println(Hex.encodeHex(source));
byte[] decompressed = decompressor.decompress(source);
Assert.assertEquals("Lorem ipsum", EncodingUtils.constructInternalEncodingString(decompressed));
}
</pre>
was (Author: malejpavouk):
7801f3c92f4acd55c82c282ecd05001907044e - BEST_COMPRESSION
789cf3c92f4acd55c82c282ecd05001907044e - BEST_SPEED
78daf3c92f4acd55c82c282ecd05001907044e -DEFAULT_COMPRESSION
import java.util.zip.Deflater;
import java.util.zip.DeflaterInputStream;
private void compressAndVerify(int level) throws IOException {
Deflater deflater = new Deflater(level);
DeflaterInputStream deflaterInputStream = new DeflaterInputStream(new ByteArrayInputStream("Lorem ipsum".getBytes(Constants.internalEncoding)), deflater);
byte[] source = IOUtils.toByteArray(deflaterInputStream);
System.out.println(Hex.encodeHex(source));
byte[] decompressed = decompressor.decompress(source);
Assert.assertEquals("Lorem ipsum", EncodingUtils.constructInternalEncodingString(decompressed));
}
> ZLIB magic detection support
> ----------------------------
>
> Key: TIKA-1632
> URL: https://issues.apache.org/jira/browse/TIKA-1632
> Project: Tika
> Issue Type: Improvement
> Components: detector
> Reporter: Pavel Micka
> Priority: Minor
>
> In our environment we encounter many compressed streams, one of them (which is currently not supported by Tika 1.8) is ZLIB. According to my sources and experience the magics that cover majority of ZLIB archives are these:
> <mime-type type="application/zlib">
> <_comment>Zlib Compressed Archive</_comment>
> <magic priority="45">
> <match value="\x78\x01" type="string" offset="0" />
> <match value="\x78\x9c" type="string" offset="0" />
> <match value="\x78\xda" type="string" offset="0" />
> </magic>
> </mime-type>
> Well described here:
> http://stackoverflow.com/questions/9050260/what-does-a-zlib-header-look-like
> Original RFC here:
> http://tools.ietf.org/html/rfc1950
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)