Re: Action File Upload Interceptor allowedTypes/allowedExtensions

Lukasz Lenart <[email protected]> Wed, 22 Oct 2025 19:48:17 +0200
Newsgroups gmane.comp.jakarta.struts.user
Message-ID <CAMopvkMXNLr-ORq8R30MUh-KbguocHVgpxNQJnQPRVu52762yQ@mail.gmail.com>
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=C5=BA 2025 o 15:16 Ute Kaiser <[email protected]> napisa=
=C5=82(a):
>
> Hi,
> while I know the way of setting
>         <param name=3D"actionFileUpload.allowedTypes">application/pdf</pa=
ram>
>         <param name=3D"actionFileUpload.allowedExtensions">.pdf</param>
> in struts.xml, I am looking for a way to do that in a more flexible way f=
rom my action.
>
>         <param name=3D"actionFileUpload.allowedTypes">${acceptedFileTypes=
}</param>
>         <param name=3D"actionFileUpload.allowedExtensions">${acceptedFile=
Extensions}</param>
> does not work (due to TextParseUtil.commaDelimitedStringToSet in ActractF=
ileUploadInterceptor).
>
> https://struts.apache.org/core-developers/action-file-upload mentions:
> >>
> Programmatically limiting the file type means using the information passe=
d in to your Action class via the setXContentType(String contentType) metho=
d.
> <<
> Any advice how to use this "setXContentType" method? Can not find this me=
thod in struts7 core source.
>
> Or any better idea to set allowedTypes and allowedExtensions from my acti=
on?
> (other than to write a custom interceptor)
>
> I also used <s:file accepted=3D${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]
>