[ 
https://issues.apache.org/jira/browse/TIKA-1692?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14636929#comment-14636929
 ] 

Nick Burch commented on TIKA-1692:
----------------------------------

I think loosing those parameters on the Mime Type (but not the Media Type) is 
correct. If you want the full details, stay in the Media Type world. If you 
want the details as defined in the well-known mime types database, then loosing 
parameters which aren't in the database seems OK to me

{code}
// Media Type always keeps details / parameters
String name = "application/xml; charset=UTF-8";
MediaType mt = MediaType.parse(name);
assertEquals(name, mt.toString());

// Mime type looses details not in the file
MimeType mimeType = types.getRegisteredMimeType(name);
assertEquals("application/xml", mimeType.toString());
assertEquals(".xml", mimeType.getExtension());

// But on well-known parameters stays
name = "application/dita+xml;format=map";
mt = MediaType.parse(name);
assertEquals(name, mt.toString());
mimeType = types.getRegisteredMimeType(name);
assertEquals(name, mimeType.toString());
assertEquals(".ditamap", mimeType.getExtension());
{code}

> Enable getExtension() for mime strings with parameters
> ------------------------------------------------------
>
>                 Key: TIKA-1692
>                 URL: https://issues.apache.org/jira/browse/TIKA-1692
>             Project: Tika
>          Issue Type: Improvement
>          Components: core
>            Reporter: Tim Allison
>            Priority: Trivial
>             Fix For: 1.10
>
>         Attachments: MimeUtilTest.java
>
>
> {{getExtension()}} offers a handy way to add a "detected" extension from a 
> {{MimeType}} for a file that didn't come with an extension.  However, this 
> functionality doesn't work with texty files: html, xml, css, csv, etc.  
> Let's add a static helper class (or build it into {{MimeType}}?) that will 
> output an extension for all mime types including texty mime types. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to