How to override mime-type based on already registered file extension

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to override mime-type based on already registered file extension

Christian Wolf
Hi,

I would like to override a file extension already registered in the tika-mimetypes.xml file. 

I know that the custom-mimetypes.xml file allows to register new custom mimetypes and it works well for new file extenstions (glob pattern) that do not already exist in tika-mimetypes.xml.

Lets take the following entry in tika-mimetypes.xml:

  <mime-type type="application/x-dtbresource+xml">
    <glob pattern="*.res"/>
  </mime-type>

What should I do to override the existing mime-type value to return  "application/my-specific-resource" instead of "application/x-dtbresource+xml" ?

If I override this entry in the custom-mimetypes.xml I get the following exception:
...
Caused by: org.xml.sax.SAXException: Conflicting extension pattern: .res
org.apache.tika.mime.MimeTypeException: Conflicting extension pattern: .res

I am using tika 1.19.1

Thanks for your help
Christian
Reply | Threaded
Open this post in threaded view
|

Re: How to override mime-type based on already registered file extension

David Meikle
HI,

On 12 Nov 2018, at 16:35, Christian Wolf <[hidden email]> wrote:


I would like to override a file extension already registered in the tika-mimetypes.xml file. 

I know that the custom-mimetypes.xml file allows to register new custom mimetypes and it works well for new file extenstions (glob pattern) that do not already exist in tika-mimetypes.xml.

Lets take the following entry in tika-mimetypes.xml:

  <mime-type type="application/x-dtbresource+xml">
    <glob pattern="*.res"/>
  </mime-type>

What should I do to override the existing mime-type value to return  "application/my-specific-resource" instead of "application/x-dtbresource+xml" ?


We would not normally recommend overriding existing mime-types but if you have to do it you can copy tika-mimetypes.xml and then place it at the front of your classpath in the package/folder org.apache.tika.mime, this will then override the default. 

Cheers,
Dave