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

Guillaume Déflache guillaume.deflache at wyona.com
Mon May 11 20:31:58 CEST 2009


Hi!

I am replying here as I know not everyone reads Bugzilla ;) and because
it's probably a friendlier place to discuss things!

bugzilla at wyona.com schrieb:
> http://bugzilla.wyona.com/cgi-bin/bugzilla/show_bug.cgi?id=7117
> 
>            Summary: add more mime-type to guessMimeType(String extension)
>            Product: Yanel
>            Version: 0.9
>           Platform: PC
>         OS/Version: Linux
>             Status: NEW
>           Severity: normal (C)
>           Priority: P2
>          Component: Servlet
>         AssignedTo: michael.wechner at wyona.org
>         ReportedBy: simon.litwan at wyona.org
>          QAContact: yanel-development at wyona.com
> 
> 
> at the moment not much mime-type are guessed.
> 
> 

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.

Cheers,
    Guillaume


More information about the Yanel-development mailing list