You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Richard HALLIER <fr...@laposte.net> on 2005/10/25 18:16:37 UTC

[COMMONS-UPLOAD] Mime-type detection

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 ????
Thank you.
R.


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


RE: [COMMONS-UPLOAD] Mime-type detection

Posted by Richard HALLIER <fr...@laposte.net>.
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 <fr...@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


Re: [COMMONS-UPLOAD] Mime-type detection

Posted by Martin Cooper <ma...@apache.org>.
On 10/25/05, Richard HALLIER <fr...@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
>
>