Re: No fielderror for empty files with ActionFileUploadInterceptor

Lukasz Lenart <[email protected]> Wed, 1 Oct 2025 18:14:22 +0200
Newsgroups gmane.comp.jakarta.struts.user
Message-ID <CAMopvkNAzxi2YOZ3pQ0pSD4p4xor2p3R_jaK7MaqhpGuGjdxmQ@mail.gmail.com>
Please check the latest 6.8.0 (under vote) or 7.1.1 (test build is
ready) versions as this behaviour has changed
https://issues.apache.org/jira/browse/WW-5366

=C5=9Br., 1 pa=C5=BA 2025 o 18:12 Ute Kaiser <[email protected]> napisa=
=C5=82(a):
>
> Hi,
>
> I would appreaciate a field error when I try to upload an empty file.
>
> I only find a server log warning
> WARN  [org.apache.struts2.interceptor.ActionFileUploadInterceptor] (defau=
lt task-2) Es konnte kein Dateiname f=C3=BCr uploadDe ermittelt werden. =C3=
=9Cberpr=C3=BCfen Sie ob eine g=C3=BCltige Datei =C3=BCbermittelt wurde.
> (German properties-Key struts.messages.invalid.file=3DCould not find a Fi=
lename for {0}. Verify that a valid file was submitted.)
>
> ActionFileUploadInterceptor.intercept runs into the if, so all nice error=
s from acceptFile are not reachable.
>             if (uploadedFiles =3D=3D null || uploadedFiles.length =3D=3D =
0) {
>                 if (LOG.isWarnEnabled()) {
>                     LOG.warn(getTextMessage(action, STRUTS_MESSAGES_INVAL=
ID_FILE_KEY, new String[]{inputName}));
>                 }
>             } else {
>                 for (UploadedFile uploadedFile : uploadedFiles) {
>                     if (acceptFile(action, uploadedFile, uploadedFile.get=
OriginalName(), uploadedFile.getContentType(), inputName)) {
>                         acceptedFiles.add(uploadedFile);
>                     }
>                 }
>             }
>
> It seems impossible to write a field error on my own.
> (I have 3 upload options, so I can not raise an error if one of them is n=
ull.)
>
> Best regards
> Ute
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>