Hi,

On Mon, Sep 30, 2013 at 10:36 AM, kevin slote <[email protected]> wrote:
> InputStream in= attachment.getFileInputStream();
> [...]
> String mime = tika.detect(in);

See the javadocs [1]: "If the document stream supports the mark
feature, then the stream is marked and reset to the original position
before this method returns"

I believe the stream you're using does not support the mark feature
(see [2]), which makes it impossible for Tika to restore the original
state of the stream once type detection is done.

Using BufferedInputStream [3] should fix your problem:

    InputStream in= new BufferedInputStream(attachment.getFileInputStream());

[1] 
http://tika.apache.org/1.4/api/org/apache/tika/Tika.html#detect(java.io.InputStream)
[2] http://docs.oracle.com/javase/7/docs/api/java/io/InputStream.html#mark(int)
[3] http://docs.oracle.com/javase/7/docs/api/java/io/BufferedInputStream.html

BR,

Jukka Zitting

Reply via email to