You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2013/03/06 15:25:33 UTC
svn commit: r1453342 - in /commons/proper/fileupload/trunk/src/site/xdoc:
overview.xml streaming.xml
Author: simonetripodi
Date: Wed Mar 6 14:25:33 2013
New Revision: 1453342
URL: http://svn.apache.org/r1453342
Log:
releng: updated samples to use lates APIs version
Modified:
commons/proper/fileupload/trunk/src/site/xdoc/overview.xml
commons/proper/fileupload/trunk/src/site/xdoc/streaming.xml
Modified: commons/proper/fileupload/trunk/src/site/xdoc/overview.xml
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/site/xdoc/overview.xml?rev=1453342&r1=1453341&r2=1453342&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/site/xdoc/overview.xml (original)
+++ commons/proper/fileupload/trunk/src/site/xdoc/overview.xml Wed Mar 6 14:25:33 2013
@@ -33,30 +33,30 @@
<p>
Assuming that you have decided that FileUpload should be invoked, you
might write the following code to handle a file upload request:
-<pre>
- // Create a new file upload handler
- DiskFileUpload upload = new DiskFileUpload();
+<source><![CDATA[DiskFileItemFactory factory = new DiskFileItemFactory();
+// Set upload parameters
+factory.setSizeThreshold(MAX_MEMORY_SIZE);
+factory.setRepository(new File(TEMP_DIR));
- // Set upload parameters
- upload.setSizeMax(MAX_UPLOAD_SIZE);
- upload.setSizeThreshold(MAX_MEMORY_SIZE);
- upload.setRepositoryPath(TEMP_DIR);
+// Create a new file upload handler
+ServletFileUpload upload = new ServletFileUpload( factory );
+upload.setSizeMax(MAX_UPLOAD_SIZE);
- // Parse the request
- List items = upload.parseRequest(request);
+// Parse the request
+List<FileItem> items = upload.parseRequest(request);
- // Process the uploaded fields
- Iterator iter = items.iterator();
- while (iter.hasNext()) {
- FileItem item = (FileItem) iter.next();
+// Process the uploaded fields
+Iterator<FileItem> iter = items.iterator();
+while (iter.hasNext()) {
+ FileItem item = iter.next();
- if (item.isFormField()) {
- processTextParameter(request, item);
- } else {
- processFileParameter(request, item);
- }
+ if (item.isFormField()) {
+ processTextParameter(request, item);
+ } else {
+ processFileParameter(request, item);
}
-</pre>
+}
+]]></source>
</p>
</section>
Modified: commons/proper/fileupload/trunk/src/site/xdoc/streaming.xml
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/site/xdoc/streaming.xml?rev=1453342&r1=1453341&r2=1453342&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/site/xdoc/streaming.xml (original)
+++ commons/proper/fileupload/trunk/src/site/xdoc/streaming.xml Wed Mar 6 14:25:33 2013
@@ -60,8 +60,7 @@ boolean isMultipart = ServletFileUpload.
Now we are ready to parse the request into its constituent items. Here's
how we do it:
</p>
-<source><![CDATA[
-// Create a new file upload handler
+<source><![CDATA[// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload();
// Parse the request