On 14-02-2009 at 22:25, ziscloud wrote:
> I'm using stripes 1.5 to develop one online submission system, and the user
> will upload their paper and other document as one rar file.
> The problem is that in the action bean, I must validate the type of the file
> user try to upload, but I invoke the getContentType() method of FileBean, I
> just get application/octet-stream.
> I have add below code into the web.xml of tomcat,
> <mime-mapping>
> <extension>rar</extension>
> <mime-type>application/rar</mime-type>
> </mime-mapping>
> What I can do to get the correct contentType?
You can't: the content type is reported by the browser, which appearently
doesn't understand the correct MIME type. Internet Explorer is notorious for
this, as it uses the extension to determine MIME types itself rather than
using the MIME type. It assumes the rest of the world is (partially) stuck in
the 8.3 filename structure as well.
What you can do is map the first few bytes of the file to the MIME type
yourself (the so called magic number). If that fails, you can map the
extension instead.
Usually, I use sites like these to find the magic numbers and MIME types:
http://filext.com/
http://file-extension.net/seeker/
Oscar
--
,-_ Oscar Westra van holthe - Kind http://www.xs4all.nl/~kindop/
/() )
(__ ( A: Because people normally read from top to bottom.
=/ () Q: Why is top-posting such a bad thing?
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users