Re: Action File Upload Interceptor allowedTypes/allowedExtensions
Lukasz Lenart <[email protected]> Wed, 12 Nov 2025 13:31:50 +0100
| Newsgroups | gmane.comp.jakarta.struts.user |
|---|---|
| Message-ID | <CAMopvkMNiZ5QgG3WffBC2GwOq1zqT9PCkAsioJSf=-jj6gBWRQ@mail.gmail.com> |
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-parameters =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]> napisa= =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</param> > > in struts.xml, I am looking for a way to do that in a more flexible way= from my action. > > > > <param name=3D"actionFileUpload.allowedTypes">${acceptedFileTyp= es}</param> > > <param name=3D"actionFileUpload.allowedExtensions">${acceptedFi= leExtensions}</param> > > does not work (due to TextParseUtil.commaDelimitedStringToSet in Actrac= tFileUploadInterceptor). > > > > https://struts.apache.org/core-developers/action-file-upload mentions: > > >> > > Programmatically limiting the file type means using the information pas= sed in to your Action class via the setXContentType(String contentType) met= hod. > > << > > 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 ac= tion? > > (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 impo= rt function (without struts). > > > > Best regards > > Ute > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: [email protected] > >