I think right now there is no better approach than performing
validation in your action when using UploadedFilesAware interface and
withUploadedFiles() method. You validate the extensions directly in
the method or use the validate() method to perform this later.

niedz., 19 paź 2025 o 15:16 Ute Kaiser <[email protected]> napisał(a):
>
> Hi,
> while I know the way of setting
>         <param name="actionFileUpload.allowedTypes">application/pdf</param>
>         <param name="actionFileUpload.allowedExtensions">.pdf</param>
> in struts.xml, I am looking for a way to do that in a more flexible way from 
> my action.
>
>         <param 
> name="actionFileUpload.allowedTypes">${acceptedFileTypes}</param>
>         <param 
> name="actionFileUpload.allowedExtensions">${acceptedFileExtensions}</param>
> does not work (due to TextParseUtil.commaDelimitedStringToSet in 
> ActractFileUploadInterceptor).
>
> https://struts.apache.org/core-developers/action-file-upload mentions:
> >>
> Programmatically limiting the file type means using the information passed in 
> to your Action class via the setXContentType(String contentType) method.
> <<
> Any advice how to use this "setXContentType" method? Can not find this method 
> in struts7 core source.
>
> Or any better idea to set allowedTypes and allowedExtensions from my action?
> (other than to write a custom interceptor)
>
> I also used <s:file accepted=${acceptedFileTypes}
> but the focus of my application is more on the extensions.
> The upload with struts must match the application's parallel batch import 
> function (without struts).
>
> Best regards
> Ute
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to