m0z4rt
m0z4rt

Reputation: 1225

What are the "allowedTypes" for .rar file (interceptor "fileUpload") in struts2?

<package name="my-default" extends="struts-default" namespace="/">
<interceptors>
<interceptor-stack name="globalInterceptor">
.....
    <interceptor-ref name="fileUpload">
     <param name="maximumSize">1048576</param>
     <param name="allowedTypes">application/x-rar-compressed</param>
    </interceptor-ref>
.....
</interceptor-stack>
</interceptors>
....
</struts>

I want to mine type for .rar file in struts2 which interceptor "fileUpload", but when I define "allowedTypes" which "application/x-rar-compressed", It doesn't work.

How can I resolve this?

Upvotes: 1

Views: 2860

Answers (3)

shibu
shibu

Reputation: 1

try <param name="allowedExtensions ">rar</param>

Upvotes: 0

Mukus
Mukus

Reputation: 5033

These are the allowed type values -

image/gif,image/jpeg,image/png,image/bmp,application/msword,text/plain,application/pdf,application/ms-excel,application/vnd.ms-excel,image/bitmap

Rar and zip are not one of them.

Upvotes: 1

leonbloy
leonbloy

Reputation: 75966

The MIME type is set by your browser, and this (specially for a .rar file type, not so popular as others) is not fully previsible - I suspect it can vary from browser to browser. If want to play safe, you can omit the allowedTypes option and do the check programatically in your action. Perhaps you'll want also (not as an alternative, but as an complementary check) to check the file extension in the client side, with Javascript.

Upvotes: 0

Related Questions