Action File Upload Interceptor allowedTypes/allowedExtensions
Ute Kaiser <[email protected]> Sun, 19 Oct 2025 13:16:09 +0000
| Newsgroups | gmane.comp.jakarta.struts.user |
|---|---|
| Message-ID | <trinity-05e75441-66bd-43e7-a556-6a8552ddcd4b-1760879769574@trinity-msg-rest-webde-webde-live-f747bc64b-nspcf> |
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 fr=
om my action.
<param name=3D"actionFileUpload.allowedTypes">${acceptedFileTypes}</param=
>
<param name=3D"actionFileUpload.allowedExtensions">${acceptedFileExtensio=
ns}</param>
does not work (due to TextParseUtil.commaDelimitedStringToSet in ActractFi=
leUploadInterceptor).
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) metho=
d.=20
<<
Any advice how to use this "setXContentType" method? Can not find this met=
hod in struts7 core source.
Or any better idea to set allowedTypes and allowedExtensions from my actio=
n?
(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