commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard HALLIER" <fred.lamue...@laposte.net>
Subject RE: [COMMONS-UPLOAD] Mime-type detection
Date Tue, 25 Oct 2005 19:21:09 GMT
Thank you Martin, I did some tests that drive me to the same conclusions. So
I have to set myself the content-type from the extension of the file.
Thank you for your help.
R.

-----Message d'origine-----
De : mfncooper@gmail.com [mailto:mfncooper@gmail.com]De la part de
Martin Cooper
Envoyé : mardi 25 octobre 2005 19:36
À : Jakarta Commons Users List
Objet : Re: [COMMONS-UPLOAD] Mime-type detection


On 10/25/05, Richard HALLIER <fred.lamuette@laposte.net> 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: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message