You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Roman Grigoriadi <ro...@gmail.com> on 2014/10/21 15:39:09 UTC

org.apache.wicket.util.upload.FileUploadBase#fileSizeMax

Hi Wicket users,

I am trying to check size of a single file in a multi file upload POST
request. It seems there is a parameter for this in "FileUploadBase" class
called "fileSizeMax" which is used for checking length of an input stream
for a file during parsing request and writing files to disk temp. Is there
any way to propagate this parameter inside considering use of default
"MultipartServletWebRequestImpl" ?

I am using wicket 6.11.0

Thanks, best regards!

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/org-apache-wicket-util-upload-FileUploadBase-fileSizeMax-tp4668001.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: org.apache.wicket.util.upload.FileUploadBase#fileSizeMax

Posted by Roman Grigoriadi <ro...@gmail.com>.
I'll try to checkout sources and create a ticket with a patch included.

Regards, Roman.



Martin Grigorov-4 wrote
> I was suggesting to do both of them.
> Please file a ticket in JIRA and I'll implement it. Or attach a patch/send
> a pull request if you have the time :-)
> Thanks!



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/org-apache-wicket-util-upload-FileUploadBase-fileSizeMax-tp4668001p4668043.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: org.apache.wicket.util.upload.FileUploadBase#fileSizeMax

Posted by Martin Grigorov <mg...@apache.org>.
I was suggesting to do both of them.
Please file a ticket in JIRA and I'll implement it. Or attach a patch/send
a pull request if you have the time :-)
Thanks!

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Wed, Oct 22, 2014 at 3:08 PM, Roman Grigoriadi <
roman.grigoriadi@gmail.com> wrote:

> First approach will be configurable per form, while second only per
> /MultipartServletWebRequestImpl/. For setting fileSizeMax by second
> approach
> you will have also to override
>
> /org.apache.wicket.protocol.http.servlet.ServletWebRequest#newMultipartWebRequest(...)/.
> On the other hand, second approach will expose FileUpload for custom
> configuration/implementation, it feels more flexible, for example I can't
> see where /FileUploadBase#setProgressListener(..)/ can be called in similar
> manner to setFileSizeMax().
>
> I would go with first option due to simplicity and configuration /per
> form/,
> or with both for more flexibility.
>
> Thank you Martin for your time and suggestion.
>
>
> Martin Grigorov-4 wrote
> > I see two improvements here:
> > 1) add Form#fileSizeMax and pass it to MultipartServletWebRequest
> > 2) add MultipartServletWebRequestImpl#newFileUpload(FileItemFactory) that
> > applications can override if they need to set some more custom settings
> >
> > What do you think ?
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/org-apache-wicket-util-upload-FileUploadBase-fileSizeMax-tp4668001p4668037.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: org.apache.wicket.util.upload.FileUploadBase#fileSizeMax

Posted by Roman Grigoriadi <ro...@gmail.com>.
First approach will be configurable per form, while second only per
/MultipartServletWebRequestImpl/. For setting fileSizeMax by second approach
you will have also to override
/org.apache.wicket.protocol.http.servlet.ServletWebRequest#newMultipartWebRequest(...)/.
On the other hand, second approach will expose FileUpload for custom
configuration/implementation, it feels more flexible, for example I can't
see where /FileUploadBase#setProgressListener(..)/ can be called in similar
manner to setFileSizeMax(). 

I would go with first option due to simplicity and configuration /per form/,
or with both for more flexibility.

Thank you Martin for your time and suggestion.


Martin Grigorov-4 wrote
> I see two improvements here:
> 1) add Form#fileSizeMax and pass it to MultipartServletWebRequest
> 2) add MultipartServletWebRequestImpl#newFileUpload(FileItemFactory) that
> applications can override if they need to set some more custom settings
> 
> What do you think ?



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/org-apache-wicket-util-upload-FileUploadBase-fileSizeMax-tp4668001p4668037.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: org.apache.wicket.util.upload.FileUploadBase#fileSizeMax

Posted by Martin Grigorov <mg...@apache.org>.
As far as I see there is no way to set FileUploadBase#fileSizeMax at the
moment.

I see two improvements here:
1) add Form#fileSizeMax and pass it to MultipartServletWebRequest
2) add MultipartServletWebRequestImpl#newFileUpload(FileItemFactory) that
applications can override if they need to set some more custom settings

What do you think ?

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Wed, Oct 22, 2014 at 1:12 PM, Roman Grigoriadi <
roman.grigoriadi@gmail.com> wrote:

> Martin, sorry, but "maxSize" is not the "maxFileSize" (which I am asking
> for). See javadoc comments in FileUploadBase:
>
> *maxSize:*/The maximum size permitted for the complete request, as opposed
> to {@link #fileSizeMax}./
>
> *fileSizeMax:*/The maximum size permitted for a single uploaded file, as
> opposed to {@link #sizeMax}/
>
> My appologies for mispelling attribute name in original post.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/org-apache-wicket-util-upload-FileUploadBase-fileSizeMax-tp4668001p4668033.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: org.apache.wicket.util.upload.FileUploadBase#fileSizeMax

Posted by Roman Grigoriadi <ro...@gmail.com>.
Martin, sorry, but "maxSize" is not the "maxFileSize" (which I am asking
for). See javadoc comments in FileUploadBase:

*maxSize:*/The maximum size permitted for the complete request, as opposed
to {@link #fileSizeMax}./

*fileSizeMax:*/The maximum size permitted for a single uploaded file, as
opposed to {@link #sizeMax}/

My appologies for mispelling attribute name in original post.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/org-apache-wicket-util-upload-FileUploadBase-fileSizeMax-tp4668001p4668033.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: org.apache.wicket.util.upload.FileUploadBase#fileSizeMax

Posted by Martin Grigorov <mg...@apache.org>.
MultipartServletWebRequestImpl receives 'maxSize' at [1].
And sets it later to the fileUpload at [2].

1.
https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/MultipartServletWebRequestImpl.java#L124
2.
https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/MultipartServletWebRequestImpl.java#L164

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Wed, Oct 22, 2014 at 11:19 AM, Roman Grigoriadi <
roman.grigoriadi@gmail.com> wrote:

> Martin, thank you for your responses, but I don't think you understand
> what I
> am asking about.
>
> My question was purely about Wicket API, not about how containers
> implementing receiving request stream. I am not trying to stop container
> processing input stream. I want to tell user in an ajax response, that one
> of attached files was too large. I actually know how to do it other way,
> but
> again, I started this thread, because I want to use FileUploadBase's
> maxFileSize, which is purely Wicket business, but it seems there is no way
> to propagate parameter in, as MultipartServletWebRequestImpl doesn't
> receive
> in constructor any.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/org-apache-wicket-util-upload-FileUploadBase-fileSizeMax-tp4668001p4668023.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: org.apache.wicket.util.upload.FileUploadBase#fileSizeMax

Posted by Roman Grigoriadi <ro...@gmail.com>.
Martin, thank you for your responses, but I don't think you understand what I
am asking about. 

My question was purely about Wicket API, not about how containers
implementing receiving request stream. I am not trying to stop container
processing input stream. I want to tell user in an ajax response, that one
of attached files was too large. I actually know how to do it other way, but
again, I started this thread, because I want to use FileUploadBase's
maxFileSize, which is purely Wicket business, but it seems there is no way
to propagate parameter in, as MultipartServletWebRequestImpl doesn't receive
in constructor any. 

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/org-apache-wicket-util-upload-FileUploadBase-fileSizeMax-tp4668001p4668023.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: org.apache.wicket.util.upload.FileUploadBase#fileSizeMax

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

There is no standard way to accomplish this so the web containers (e.g.
Tomcat, Jetty, ...) provide custom settings to do what you want. See [1]
Wicket uses standard Servlet APIs and it either receives the whole input
stream or nothing.

You have to consult with the documentation of the web container you use.

1. https://issues.apache.org/jira/browse/WICKET-3525

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Wed, Oct 22, 2014 at 7:59 AM, Roman Grigoriadi <
roman.grigoriadi@gmail.com> wrote:

> I am trying to check size of each of uploaded files, when there is more
> than
> one file in one POST request.
>
> While there may be other way to do so, it looks like fileSizeMax in
> FileUploadBase, does just the right thing, aborting processing multipart
> POST by throwing FileUploadException which causes a call to
> Form.onFileUploadException.
>
> I would like to use it this way, instead of a check after POST request is
> parsed and files are copied to disk, but I don't see any way to propagate
> the parameter in. Could it be that MultipartServletWebRequestImpl (which
> creates FileUploadBase objects) has forgotten to propagate fileSizeMax
> inside FileUploadBase?
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/org-apache-wicket-util-upload-FileUploadBase-fileSizeMax-tp4668001p4668018.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: org.apache.wicket.util.upload.FileUploadBase#fileSizeMax

Posted by Roman Grigoriadi <ro...@gmail.com>.
I am trying to check size of each of uploaded files, when there is more than
one file in one POST request. 

While there may be other way to do so, it looks like fileSizeMax in
FileUploadBase, does just the right thing, aborting processing multipart
POST by throwing FileUploadException which causes a call to
Form.onFileUploadException.

I would like to use it this way, instead of a check after POST request is
parsed and files are copied to disk, but I don't see any way to propagate
the parameter in. Could it be that MultipartServletWebRequestImpl (which
creates FileUploadBase objects) has forgotten to propagate fileSizeMax
inside FileUploadBase?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/org-apache-wicket-util-upload-FileUploadBase-fileSizeMax-tp4668001p4668018.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: org.apache.wicket.util.upload.FileUploadBase#fileSizeMax

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

It is not clear to me what you want to accomplish.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Tue, Oct 21, 2014 at 4:39 PM, Roman Grigoriadi <
roman.grigoriadi@gmail.com> wrote:

> Hi Wicket users,
>
> I am trying to check size of a single file in a multi file upload POST
> request. It seems there is a parameter for this in "FileUploadBase" class
> called "fileSizeMax" which is used for checking length of an input stream
> for a file during parsing request and writing files to disk temp. Is there
> any way to propagate this parameter inside considering use of default
> "MultipartServletWebRequestImpl" ?
>
> I am using wicket 6.11.0
>
> Thanks, best regards!
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/org-apache-wicket-util-upload-FileUploadBase-fileSizeMax-tp4668001.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>