Re: Action File Upload Interceptor allowedTypes/allowedExtensions

Lukasz Lenart <[email protected]> Fri, 21 Nov 2025 09:06:51 +0100
Newsgroups gmane.comp.jakarta.struts.user
Message-ID <CAMopvkNG=OvOwZ=gC6iCHCALA6BS=zYA=DNLvj-xSFWwoPwzZQ@mail.gmail.com>
PR is ready, I also identified a few other issues
https://github.com/apache/struts/pull/1413

=C5=9Br., 12 lis 2025 o 13:31 Lukasz Lenart <[email protected]> napis=
a=C5=82(a):
>
> I created a ticket [1] to address this problem, this should be easily
> resolved by using WithLazyParams [2]
>
> [1] https://issues.apache.org/jira/browse/WW-5585
> [2] https://struts.apache.org/core-developers/interceptors#lazy-parameter=
s
>
> =C5=9Br., 22 pa=C5=BA 2025 o 19:48 Lukasz Lenart <[email protected]=
> napisa=C5=82(a):
> >
> > 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]> napi=
sa=C5=82(a):
> > >
> > > Hi,
> > > while I know the way of setting
> > >         <param name=3D"actionFileUpload.allowedTypes">application/pdf=
</param>
> > >         <param name=3D"actionFileUpload.allowedExtensions">.pdf</para=
m>
> > > in struts.xml, I am looking for a way to do that in a more flexible w=
ay from my action.
> > >
> > >         <param name=3D"actionFileUpload.allowedTypes">${acceptedFileT=
ypes}</param>
> > >         <param name=3D"actionFileUpload.allowedExtensions">${accepted=
FileExtensions}</param>
> > > does not work (due to TextParseUtil.commaDelimitedStringToSet in Actr=
actFileUploadInterceptor).
> > >
> > > https://struts.apache.org/core-developers/action-file-upload mentions=
:
> > > >>
> > > Programmatically limiting the file type means using the information p=
assed in to your Action class via the setXContentType(String contentType) m=
ethod.
> > > <<
> > > Any advice how to use this "setXContentType" method? Can not find thi=
s 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=3D${acceptedFileTypes}
> > > but the focus of my application is more on the extensions.
> > > The upload with struts must match the application's parallel batch im=
port function (without struts).
> > >
> > > Best regards
> > > Ute
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [email protected]
> > > For additional commands, e-mail: [email protected]
> > >