【发布时间】:2022-01-06 13:20:16
【问题描述】:
使用 docx 文件,我检索 application/x-tika-ooxml,但我应该检索 application/vnd.openxmlformats-officedocument.wordprocessingml.document
这是我的方法:
public String retrieveMimeType(InputStream stream) throws IOException, TikaException {
TikaInputStream tikaStream = null;
TikaConfig tikaConfig = new TikaConfig();
MediaType mediaType = null;
try {
mediaType = tikaConfig.getDetector().detect(TikaInputStream.get(stream), new Metadata());
} catch (Throwable t) {
throw t;
} finally {
if (tikaStream != null) {
try {
tikaStream.close();
} catch (IOException e) {
}
}
}
return mediaType.toString();
}
还有我的依赖:
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-parsers</artifactId>
<version>1.27</version>
</dependency>
我使用 tika-core 和 tika-parsers 来检索正确的 mimetype,但它仍然给我错误的 mimetype...
【问题讨论】:
标签: java pom.xml apache-tika