commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Cooper <>
Subject Re: [COMMONS-UPLOAD] Mime-type detection
Date Tue, 25 Oct 2005 17:36:13 GMT
On 10/25/05, Richard HALLIER <> wrote:
> Hi all,
> I have some problems by filtering the files the user can upload in my
> webapp. I'd like to restrict the files to the flash videos (extension
> .flv),
> so I disallow the files whose the mime-type is different from video/x-flv.
> The problem is Commons-upload gives me the wrong mime-type :
> application/octet-stream
> Ok, so I added the mime-mapping my web.xml :
> <mime-mapping>
> <extension>flv</extension>
> <mime-type>video/x-flv</mime-type>
> </mime-mapping>
> Nothing changes ....
> Can someone give me some pointers ????

Commons FileUpload isn't giving you the wrong MIME type - it's giving you
exactly what the browser gave it. What the browser gives it is entirely up
to the browser, and I don't believe you have much control over that, short
of having all your users update their own browser settings.

As for the <mime-mapping> element, the Servlet spec is hopelessly vague on
this, but I believe it is used only for downloads. Note that the Servlet
spec does not involve itself with the upload process at all.

I believe you'll just have to look at the file extensions yourself, after
the files are uploaded.

Martin Cooper

Thank you.
> R.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message