[Yanel-dev] [Bug 7117] New: add more mime-type to guessMimeType(String extension)

Guillaume Déflache guillaume.deflache at wyona.com
Fri Sep 25 18:11:25 CEST 2009


Guillaume Déflache schrieb:
> As the TODO there says, we should really delegate MIME-type to
> file-extension mapping to a library!
> 
> The good thing is, one already exists, and a standard one at that: JAF
> http://java.sun.com/javase/technologies/desktop/javabeans/jaf/
> So why not use javax.activation.MimetypesFileTypeMap from JAF?
> http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/activation/MimetypesFileTypeMap.html 
> 
> If we do we should be able to configure all of this in
> META-INF/mime.types *and* programmatically, or even not at all as the
> JVM defaults may be enough, and then simply use new
> MimetypesFileTypeMap().getContentType(java.lang.String filename)!
> 
> JAF (not sure which version) is included by default from J2SE 6 onwards
> and IIRC is already in J2EE so we probably should add it as an endorsed
> library.
> Note: it looks like the standard Yanel distribution was already pulling
> activation-1.1.jar...
> 
> If your needs are not met by JAF you might also want to have a look at
> the (Apache-licensed) mime-util library
> http://www.theserverside.com/news/thread.tss?thread_id=53892
> http://sourceforge.net/projects/mime-util/
> There might also some Jakarta Commons at Apache providing this, haven't
> looked at it.

FYI Nutch also has a similar one named "getMimeType" in the MimeTypes 
class: 
http://lucene.apache.org/nutch/apidocs/org/apache/nutch/util/mime/MimeTypes.html

However it seems Nutch has never been available in the main Maven repo! 
:( Any idea how to get that class from Maven?
[ BTW I already saw in a customer project using some other Java source 
classes from Nutch that were copied verbatim, maybe that's the reason! ;) ]


More information about the Yanel-development mailing list