[ https://issues.apache.org/jira/browse/TIKA-4441?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17986216#comment-17986216 ]
ASF GitHub Bot commented on TIKA-4441: -------------------------------------- tballison opened a new pull request, #2261: URL: https://github.com/apache/tika/pull/2261 <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> Thanks for your contribution to [Apache Tika](https://tika.apache.org/)! Your help is appreciated! Before opening the pull request, please verify that * there is an open issue on the [Tika issue tracker](https://issues.apache.org/jira/projects/TIKA) which describes the problem or the improvement. We cannot accept pull requests without an issue because the change wouldn't be listed in the release notes. * the issue ID (`TIKA-XXXX`) - is referenced in the title of the pull request - and placed in front of your commit messages surrounded by square brackets (`[TIKA-XXXX] Issue or pull request title`) * commits are squashed into a single one (or few commits for larger changes) * Tika is successfully built and unit tests pass by running `mvn clean test` * there should be no conflicts when merging the pull request branch into the *recent* `main` branch. If there are conflicts, please try to rebase the pull request branch on top of a freshly pulled `main` branch * if you add new module that downstream users will depend upon add it to relevant group in `tika-bom/pom.xml`. We will be able to faster integrate your pull request if these conditions are met. If you have any questions how to fix your problem or about using Tika in general, please sign up for the [Tika mailing list](http://tika.apache.org/mail-lists.html). Thanks! > InputStream is consumed by Tika.detect for certain files > -------------------------------------------------------- > > Key: TIKA-4441 > URL: https://issues.apache.org/jira/browse/TIKA-4441 > Project: Tika > Issue Type: Bug > Affects Versions: 3.2.0, 3.2.1 > Reporter: Alvaro > Priority: Major > Attachments: Test.doc, Test.ppt, Test.xls > > > Hello, > We've been using Tika version 3.1.0 to successfully detect MimeTypes from > files before uploading them to our S3. > However, after v3.2.0 upgrade, we've noticed that the original inputStream is > being consumed entirely for certain file extensions. > The affected extensions seem to be all for Microsoft files, pointing us to > the POIFSContainerDetector, which was actually changed for this release. > This is the list of extensions we've tested with errors: doc, docx, odt, ppt, > pptx, xls, xlsx > And these ones work as before: bmp, csv, gif, jpeg, jpg, pdf, png, rtf, svg, > txt > > Here's some code to reproduce the issue: > {code:java} > class TikaBugReport { > // affected extensions: doc, docx, odt, ppt, pptx, xls, xlsx > public static void main(String[] args) throws IOException { > String fileName = "Test.docx"; > InputStream inputStream = new > ClassPathResource(fileName).getInputStream(); > checkFileMime(inputStream, fileName); > } > public static void checkFileMime(InputStream inputStream, String > fileName) { > try { > Tika tika = new Tika(); > System.out.println("InputStream available bytes before > processing: " + inputStream.available()); > System.out.println("InputStream supports mark: " + > inputStream.markSupported()); > Metadata metadata = new Metadata(); > TikaInputStream tikaInputStream = > TikaInputStream.get(inputStream); > System.out.println("Original InputStream available bytes after > TikaInputStream.get(): " + inputStream.available()); > String mimeType = tika.detect(tikaInputStream, metadata); > // Debug: Check state after detection > System.out.println("Original InputStream available bytes after > tika.detect(): " + inputStream.available()); > System.out.println("TikaInputStream available bytes after > tika.detect(): " + tikaInputStream.available()); > if (inputStream.available() == 0) { > throw new IllegalStateException("InputStream is empty after > TikaInputStream creation"); > } > } catch (Exception e) { > System.out.printf("Mime check exception for file '%s': [%s]%n", > fileName, e.getMessage()); > } > } > }{code} > After testing version 3.2.1, the issue is fixed for most file extensions, but > .doc, .ppt and .xls extensions are still failing. Find sample files attached > -- This message was sent by Atlassian Jira (v8.20.10#820010)