[
https://issues.apache.org/jira/browse/TIKA-2611?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16409181#comment-16409181
]
Andreas Meier commented on TIKA-2611:
-------------------------------------
As [~gagravarr] already mentioned you should try to get the latest build and
check again.
The file should be recognized correctly as javascript-file by the fileextension.
If you want to detect files like this without fileextension ".js" you could add
one more matcher to the javascript Magic in tika-mimetypes.xml:
{code:xml}
<match value="\012(function(" type="string" offset="0" />
{code}
Note: This will only be a workaround for this specific case, since emacs 18 and
earlier might also start with "\012(function"
> Tika mistakenly determines mimetype of .js file as application/x-elc
> --------------------------------------------------------------------
>
> Key: TIKA-2611
> URL: https://issues.apache.org/jira/browse/TIKA-2611
> Project: Tika
> Issue Type: Bug
> Components: detector
> Affects Versions: 1.17
> Reporter: Anto
> Priority: Major
> Fix For: 1.18
>
> Attachments: 980x240_edge.js
>
>
> Attached file is misinterpreted as being an application/x-elc file when it's
> really just a plain javascript file.
> Using:
> {code:java}
> private final DefaultDetector mimeTypeDetector = new DefaultDetector();
> public String determineMimeType(final byte[] data, final String fileName) {
> final TikaInputStream inputStream = TikaInputStream.get(data);
> final Metadata metadata = new Metadata();
> metadata.set(Metadata.RESOURCE_NAME_KEY, fileName);
> try {
> return mimeTypeDetector.detect(inputStream, metadata).toString();
> } catch (final IOException e) {
> throw new ApiException(e);
> }
> }{code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)