You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Andy Stevens <in...@googlemail.com> on 2008/01/29 01:20:59 UTC
Is it possible to restrict file uploads to certain URLs?
Hi,
New year, new webmail; hopefully google mangles embedded xml less than
hotmail :-)
I have a new requirement for one of our sites to allow the users to
upload some files. However, I read in the Cocoon docs/wiki that
switching on the enable-uploads init parameter will make it use the
multipart request factory etc. on all requests it receives. This
seems to me like a lot of unnecessary work (and either disk IO or heap
churn) when only a couple of pipelines will be processing the uploaded
files.
Since the URLs that will handle the file Part(s) are all in a specific
area of the site (a subdirectory requiring the user to have logged
in), I was wondering whether it was possible to configure Cocoon (with
a regex, say) to only use the multipart parser on a subset of the URL
space. If not, would this be a considered a generally useful feature
if I can come up with a patch?
Andy.
--
http://pseudoq.sourceforge.net/ Open source java Sudoku application
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Is it possible to restrict file uploads to certain URLs?
Posted by Joerg Heinicke <jo...@gmx.de>.
On 29.01.2008 01:20, Andy Stevens wrote:
> I have a new requirement for one of our sites to allow the users to
> upload some files. However, I read in the Cocoon docs/wiki that
> switching on the enable-uploads init parameter will make it use the
> multipart request factory etc. on all requests it receives. This
> seems to me like a lot of unnecessary work (and either disk IO or heap
> churn) when only a couple of pipelines will be processing the uploaded
> files.
If you look at the actual implementation you will see that there isn't a
real overhead:
CocoonServlet.service(..):
if (this.enableUploads) {
request = requestFactory.getServletRequest(req);
} else {
request = req;
}
That's exactly what you described, as soon as uploads are enabled
multipart request factory is used.
RequestFactory.getServletRequest(..):
String contentType = request.getContentType();
if ((contentType != null) &&
(contentType.toLowerCase().indexOf("multipart/form-data") > -1)) {
// wrap request object in MultipartHttpServletRequest
}
return request;
This means the actual multipart parsing is triggered only by form
content type "multipart/form-data" - and that's what you have to set
explicitly on the form. So the overhead is only to check for that
particular request property.
Joerg
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org