You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by tatan123 <ni...@gmail.com> on 2009/06/14 04:34:53 UTC

How to limit file upload size without full upload

We want to restrict the file upload size to 2 MB. While doing testing it
seems we can upload a 100 MB file, after that struts2 showing message that
the uploaded file exceeds the max file size limit. Is there any way struts2
can show the error message without full file upload...

Thanks
-- 
View this message in context: http://www.nabble.com/How-to-limit-file-upload-size-without-full-upload-tp24018123p24018123.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: How to limit file upload size without full upload

Posted by Martin Gainty <mg...@hotmail.com>.

i assume thats the RLE of the entity you are streaming? in which case maxPostSize will
alleviate that limitation on a non-ssl HTTP 1.1 connector

there are now asynchronous connectors available which will alleviate
the majority of performance issues you are experiencing which wont be discussed here
(the topic of asynch connectors is off-topic to struts and is specific to container)

when you *finally* do arrive to the issue of whether or not to use commons-fileupload or
struts-fileupload tag with a collection or not to use a collection the implementation
details are easily discernible from the doc and can be handled by list members

the topic of transporting large files (which you will encounter with file-uploading)
is a topic worthy of serious consideration and has many implications for container architects

i believe thinking of a overall solution (vis a vis size,compression and securty) and work to smaller iterations is a good methodology to follow..others have their own methodologies

please feel free to ping me O/L for more discussion on use of asynchronous connectors..
and yes continue to ping list for implementation details on struts tags (such as CFU)

thanks
Martin 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.


> Date: Mon, 15 Jun 2009 09:51:28 -0400
> Subject: Re: How to limit file upload size without full upload
> From: wesw@wantii.com
> To: user@struts.apache.org
> 
> I've been known to be wrong before ;) unfortunately, more often than I
> would prefer :(
> 
> The next setting I would look at is in commons-fileupload, but with
> the stock file upload capabilities, you don't have a lot of options
> for changing configuration. I didn't look really close at how CFU
> behaves, but if you came back and said that it waits until the upload
> is complete before checking file size, I wouldn't be surprised. IIRC,
> the content size sent by the browser as part of the upload is not
> always reliable, leaving the upload handler to check size as it is
> receiving data. IMO, it might be hard to make it work right.
> Fortunately, there is a plugin in the sandbox that makes the upload
> capabilities more configurable, but unfortunately, you have to be
> running against a SNAPSHOT build of struts, since I had to update core
> to allow some of the configuration. If you wanna play around with it,
> since it's unreleased, be prepared to build struts and the plugin from
> scratch with maven and be patient if you find bugs.
> 
> On Mon, Jun 15, 2009 at 9:31 AM, Greg Lindholm<gr...@gmail.com> wrote:
> >
> >
> > On Sun, Jun 14, 2009 at 1:49 AM, Wes Wannemacher <we...@wantii.com> wrote:
> >>
> >> On Saturday 13 June 2009 10:34:53 pm tatan123 wrote:
> >> > We want to restrict the file upload size to 2 MB. While doing testing it
> >> > seems we can upload a 100 MB file, after that struts2 showing message
> >> > that
> >> > the uploaded file exceeds the max file size limit. Is there any way
> >> > struts2
> >> > can show the error message without full file upload...
> >> >
> >> > Thanks
> >>
> >> I could be wrong, but if you are talking about the temp file generated as
> >> the
> >> upload takes place, then you might be better off setting the max post size
> >> of
> >> your application server. In Tomcat, you can use the maxPostSize attribute
> >> of
> >> the connector element.
> >>
> >> -Wes
> >> --
> >>
> >>
> >
> > I don't think the Tomcat maxPostSize attribute applies to file uploads.
> > Here is what the Tomcat 5.5 docs say:
> >
> > The maximum size in bytes of the POST which will be handled by the container
> > FORM URL parameter parsing. The limit can be disabled by setting this
> > attribute to a value less than or equal to 0. If not specified, this
> > attribute is set to 2097152 (2 megabytes).
> >
> > I've never set this attribute and have been able to upload 20mb files.
> >
> >
> 
> 
> 
> -- 
> Wes Wannemacher
> Author - Struts 2 In Practice
> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
> http://www.manning.com/wannemacher
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
Hotmail® has ever-growing storage! Don’t worry about storage limits. 
http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM_WL_HM_Tutorial_Storage_062009

Re: How to limit file upload size without full upload

Posted by Wes Wannemacher <we...@wantii.com>.
I've been known to be wrong before ;) unfortunately, more often than I
would prefer :(

The next setting I would look at is in commons-fileupload, but with
the stock file upload capabilities, you don't have a lot of options
for changing configuration. I didn't look really close at how CFU
behaves, but if you came back and said that it waits until the upload
is complete before checking file size, I wouldn't be surprised. IIRC,
the content size sent by the browser as part of the upload is not
always reliable, leaving the upload handler to check size as it is
receiving data. IMO, it might be hard to make it work right.
Fortunately, there is a plugin in the sandbox that makes the upload
capabilities more configurable, but unfortunately, you have to be
running against a SNAPSHOT build of struts, since I had to update core
to allow some of the configuration. If you wanna play around with it,
since it's unreleased, be prepared to build struts and the plugin from
scratch with maven and be patient if you find bugs.

On Mon, Jun 15, 2009 at 9:31 AM, Greg Lindholm<gr...@gmail.com> wrote:
>
>
> On Sun, Jun 14, 2009 at 1:49 AM, Wes Wannemacher <we...@wantii.com> wrote:
>>
>> On Saturday 13 June 2009 10:34:53 pm tatan123 wrote:
>> > We want to restrict the file upload size to 2 MB. While doing testing it
>> > seems we can upload a 100 MB file, after that struts2 showing message
>> > that
>> > the uploaded file exceeds the max file size limit. Is there any way
>> > struts2
>> > can show the error message without full file upload...
>> >
>> > Thanks
>>
>> I could be wrong, but if you are talking about the temp file generated as
>> the
>> upload takes place, then you might be better off setting the max post size
>> of
>> your application server. In Tomcat, you can use the maxPostSize attribute
>> of
>> the connector element.
>>
>> -Wes
>> --
>>
>>
>
> I don't think the Tomcat maxPostSize attribute applies to file uploads.
> Here is what the Tomcat 5.5 docs say:
>
> The maximum size in bytes of the POST which will be handled by the container
> FORM URL parameter parsing. The limit can be disabled by setting this
> attribute to a value less than or equal to 0. If not specified, this
> attribute is set to 2097152 (2 megabytes).
>
> I've never set this attribute and have been able to upload 20mb files.
>
>



-- 
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to limit file upload size without full upload

Posted by Greg Lindholm <gr...@gmail.com>.
On Sun, Jun 14, 2009 at 1:49 AM, Wes Wannemacher <we...@wantii.com> wrote:

> On Saturday 13 June 2009 10:34:53 pm tatan123 wrote:
> > We want to restrict the file upload size to 2 MB. While doing testing it
> > seems we can upload a 100 MB file, after that struts2 showing message
> that
> > the uploaded file exceeds the max file size limit. Is there any way
> struts2
> > can show the error message without full file upload...
> >
> > Thanks
>
> I could be wrong, but if you are talking about the temp file generated as
> the
> upload takes place, then you might be better off setting the max post size
> of
> your application server. In Tomcat, you can use the maxPostSize attribute
> of
> the connector element.
>
> -Wes
> --
>
>
>
I don't think the Tomcat maxPostSize attribute applies to file uploads.
Here is what the Tomcat 5.5 docs say:

The maximum size in bytes of the POST which will be handled by the container
FORM URL parameter parsing. The limit can be disabled by setting this
attribute to a value less than or equal to 0. If not specified, this
attribute is set to 2097152 (2 megabytes).

I've never set this attribute and have been able to upload 20mb files.

Re: How to limit file upload size without full upload

Posted by Wes Wannemacher <we...@wantii.com>.
On Saturday 13 June 2009 10:34:53 pm tatan123 wrote:
> We want to restrict the file upload size to 2 MB. While doing testing it
> seems we can upload a 100 MB file, after that struts2 showing message that
> the uploaded file exceeds the max file size limit. Is there any way struts2
> can show the error message without full file upload...
>
> Thanks

I could be wrong, but if you are talking about the temp file generated as the 
upload takes place, then you might be better off setting the max post size of 
your application server. In Tomcat, you can use the maxPostSize attribute of 
the connector element.

-Wes
-- 

Wes Wannemacher
Author - Struts 2 In Practice 
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org