Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can ServletFileUpload.parseRequest() only be called once per request?

I'm working a custom SpringSecurityFilter for my Grails application and I'm trying to use the commons upload library to process the request. I'm able to process the request in the filter but once it gets to my controller, none of the values are available.

Can the HttpRequest only be processed once by the upload library? I'm guessing it's cleaning up the temp files. Is there a way to keep them around so they can be processed again at the controller level?

I need to interrogate a form parameter for the security (due to the client I can't add it to the http headers) but once I get the value, it seems to wipe the request for further processing.

like image 827
ahanson Avatar asked Feb 19 '10 17:02

ahanson


1 Answers

Yes. A Request can only be parsed once.

I saw this answer on Apache's FAQ page for FileUpload.

Question: Why is parseRequest() returning no items?

Answer: "This most commonly happens when the request has already been parsed, or processed in some other way. Since the input stream has aleady been consumed by that earlier process, it is no longer available for parsing by Commons FileUpload."

Reference: http://commons.apache.org/fileupload/faq.html

like image 76
Cody Avatar answered Sep 30 '22 03:09

Cody