I use Apache Tika bundle dependency for a Project to find out MimeTypes for
Files. due to some issues we have to find out through InputStream. it is
actually guaranteed to mark / reset given InputStream. Tika-Bundle includes
core and parser api and uses PoifscontainerDetector , ZipContainerDetector,
OggDetector, MimeTypes and Magic for detection. I have been debugging for 3
hours and all of Detectors mark and reset after detection. I did it in
following way.

TikaInputStream tis = null;
    try {
        TikaConfig config = new TikaConfig();
        tikaDetector = config.getDetector();
        tis =  TikaInputStream.get(in);
        MediaType mediaType = tikaDetector.detect(tis, new Metadata());

        if (mediaType != null) {
            String[] types = mediaType.toString().split(",");

            for (int i = 0; i < types.length; i++) {
                mimeTypes.add(new MimeType(types[i]));
            }
        }

    } catch (Exception e) {
        logger.error("Mime Type for given Stream could not be resolved: ",
e);
    } 

But Stream is consumed. Does anyone know how to find out MimeTypes without
consuming Stream?








--
View this message in context: 
http://lucene.472066.n3.nabble.com/Tika-Api-consumes-given-stream-tp4168960.html
Sent from the Apache Tika - Development mailing list archive at Nabble.com.

Reply via email to