[ 
https://issues.apache.org/struts/browse/WW-2580?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43596#action_43596
 ] 

Jelmer Kuperus commented on WW-2580:
------------------------------------

In our app I basically made a copy of FileUploadInterceptor similar to the one 
included in patch2.diff  to add this behaviour

The other option would have been to check for the extension in the action 
itself after binding.

I attached 2 patches,

patch1.diff - merely adds an filename argument to the acceptFile method. This 
allows subclasses to do the filtering on extension themselfes

patch2.diff - adds the filename argument to acceptFile but also adds a 
allowedExtensions property to the interceptor.

I think its a pretty common usecase to do checks based on file extension rather 
than mimetype so i would definitely prefer patch2 to be applied

I tried to keep the modifications as similar to the original code as possible 
so java 4 syntax is used for loops etc 

> Add filename argument to acceptFile method in FileUploadInterceptor
> -------------------------------------------------------------------
>
>                 Key: WW-2580
>                 URL: https://issues.apache.org/struts/browse/WW-2580
>             Project: Struts 2
>          Issue Type: New Feature
>    Affects Versions: 2.0.11.1
>            Reporter: Jelmer Kuperus
>         Attachments: patch1.diff, patch2.diff
>
>
> It would be quite usefull to extend the acceptFile  method in 
> FileUploadInterceptor with an additional argument that passes in the original 
> filename. This allows you to filter uploads based on its extension / name and 
> not merely on the content type. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to