Last updated July 07, 2009 15:06, by tbee
File Upload Filter Wiki
A simple way to handle files uploads, similar how PHP does it. You enable the filter with two simple configuration enties in web.xml;
<filter>
<filter-name>FileUploadFilter</filter-name>
<filter-class>nl.innovationinvestments.fileuploadfilter.FileUploadFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>FileUploadFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Then, once you've defined file upload input tags in a multipart form, the filter will save the contents in a temporarily files. The request is then enhanced with regular parameters specifying where these files were stored. The endpoint of the request does not need to do any special handling for multipart forms.
Example
<input type="file" name="file" size="40">
Results in the following additional parameters:
file = C:\DOCUME~1\User\LOCALS~1Temp\FileUploadFilter_2603023838504_370597244165009803508176428296563933.txt
file_contentType = text/plain
file_localFileName = test.txt
file_localFilePath = C:\tmp\test.txt
The "file" parameter contains the absolute path to a system-local file. Any temporarily files are deleted automatically, if all streams to them have been closed correctly, after the request is completed.





