You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Adam Gordon <ad...@readytalk.com> on 2008/02/08 00:35:51 UTC
File upload issues when maxFileSize is exceeded.
We're using Struts 1.2.9 and the problem we're seeing is that if a user
tries to upload a file that does not exist or upload a file that exceeds
the maxFileSize attribute the FormFile object on the ActionForm is null
and so we cannot distinguish between the two.
We thought about removing the maxFileSize parameter and doing the check
ourselves in the ActionForm, but it appears that the file upload has
already begun at that point and while we can look at the Content-Length
header from the HttpServletRequest object in the Struts Action, it's a
moot step because the file has already begun to upload.
Is there a method on Action or DispatchAction (or perhaps something
else) that we can override to prevent the file upload if it exceeds a
size we determine? My concern is that Apache commons-fileupload gets
the request to upload the file first before Struts gets it and we might
be hozed in this regard.
Any thoughts? Thanks.
--adam
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: File upload issues when maxFileSize is exceeded.
Posted by James Sanders <sa...@gmail.com>.
Thanks for your response Martin, but as Dave pointed out, we do not have
that interface available as we are using 1.2.9. Does anybody know at what
point the framework begins to actually save a FormFile and if there is any
way to hook into that and check the length before that happens?
On Feb 7, 2008 5:44 PM, Dave Newton <ne...@yahoo.com> wrote:
> --- Martin Gainty <mg...@hotmail.com> wrote:
> > take a look at implementing FileUploadAction
> >
>
> http://jsourcery.com/api/apache/struts/2.0.6/org/apache/struts2/showcase/fil
> > eupload/FileUploadAction.html
>
> "Adam Gordon" <ad...@readytalk.com> wrote:
> > > We're using Struts 1.2.9
>
> Dave
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: File upload issues when maxFileSize is exceeded.
Posted by Dave Newton <ne...@yahoo.com>.
--- Martin Gainty <mg...@hotmail.com> wrote:
> take a look at implementing FileUploadAction
>
http://jsourcery.com/api/apache/struts/2.0.6/org/apache/struts2/showcase/fil
> eupload/FileUploadAction.html
"Adam Gordon" <ad...@readytalk.com> wrote:
> > We're using Struts 1.2.9
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: File upload issues when maxFileSize is exceeded.
Posted by Martin Gainty <mg...@hotmail.com>.
Adam-
take a look at implementing FileUploadAction
http://jsourcery.com/api/apache/struts/2.0.6/org/apache/struts2/showcase/fil
eupload/FileUploadAction.html
M--
----- Original Message -----
From: "Adam Gordon" <ad...@readytalk.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Thursday, February 07, 2008 6:35 PM
Subject: File upload issues when maxFileSize is exceeded.
> We're using Struts 1.2.9 and the problem we're seeing is that if a user
> tries to upload a file that does not exist or upload a file that exceeds
> the maxFileSize attribute the FormFile object on the ActionForm is null
> and so we cannot distinguish between the two.
>
> We thought about removing the maxFileSize parameter and doing the check
> ourselves in the ActionForm, but it appears that the file upload has
> already begun at that point and while we can look at the Content-Length
> header from the HttpServletRequest object in the Struts Action, it's a
> moot step because the file has already begun to upload.
>
> Is there a method on Action or DispatchAction (or perhaps something
> else) that we can override to prevent the file upload if it exceeds a
> size we determine? My concern is that Apache commons-fileupload gets
> the request to upload the file first before Struts gets it and we might
> be hozed in this regard.
>
> Any thoughts? Thanks.
>
> --adam
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: File upload issues when maxFileSize is exceeded.
Posted by James Sanders <sa...@gmail.com>.
Thanks Laurie! That's a pretty good idea, and quite possibly what we'll do.
The problem with it is that the file is sent along with other form
parameters, and if I remember correctly, the Content-Length header is the
full length of the body of the post, which would include all the text for
those parameters as well, making it difficult to tell which portion of that
length is the file and which is the other parameters. Hmmm, anybody see a
solution to that issue?
On Feb 8, 2008 12:20 PM, Laurie Harper <la...@holoweb.net> wrote:
> Adam Gordon wrote:
> > We're using Struts 1.2.9 and the problem we're seeing is that if a user
> > tries to upload a file that does not exist or upload a file that exceeds
> > the maxFileSize attribute the FormFile object on the ActionForm is null
> > and so we cannot distinguish between the two.
> >
> > We thought about removing the maxFileSize parameter and doing the check
> > ourselves in the ActionForm, but it appears that the file upload has
> > already begun at that point and while we can look at the Content-Length
> > header from the HttpServletRequest object in the Struts Action, it's a
> > moot step because the file has already begun to upload.
>
> Couldn't you keep the maxFileSize parameter then use the Content-Length
> header to distinguish the two cases? Short of writing your own
> implementation of MultipartRequestHandler, I don't think there's anyway
> to hook into the file upload handling.
>
> L.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: File upload issues when maxFileSize is exceeded.
Posted by Laurie Harper <la...@holoweb.net>.
Adam Gordon wrote:
> We're using Struts 1.2.9 and the problem we're seeing is that if a user
> tries to upload a file that does not exist or upload a file that exceeds
> the maxFileSize attribute the FormFile object on the ActionForm is null
> and so we cannot distinguish between the two.
>
> We thought about removing the maxFileSize parameter and doing the check
> ourselves in the ActionForm, but it appears that the file upload has
> already begun at that point and while we can look at the Content-Length
> header from the HttpServletRequest object in the Struts Action, it's a
> moot step because the file has already begun to upload.
Couldn't you keep the maxFileSize parameter then use the Content-Length
header to distinguish the two cases? Short of writing your own
implementation of MultipartRequestHandler, I don't think there's anyway
to hook into the file upload handling.
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org