[Yanel-dev] Refactor max file upload size

Michael Wechner michael.wechner at wyona.com
Wed Feb 11 11:25:56 CET 2009


Hi

It seems that within

src/webapp/src/java/org/wyona/yanel/servlet/communication/HttpRequest.java

the file upload size is hard-coded and I think we should refactor it:

Index: src/resources/file/resource.xml
===================================================================
--- src/resources/file/resource.xml     (Revision 41484)
+++ src/resources/file/resource.xml     (Arbeitskopie)
@@ -18,5 +18,6 @@
   <!-- For example (IMPORTANT: Do not forget the leading slash!)
     <yanel:property name="src" value="/index.html"/>
   -->
+  <property name="max-file-upload-size"/> <!-- kilo bytes -->
 </rtd>
 </resource>


Index: 
src/resources/file/src/java/org/wyona/yanel/impl/resources/node/NodeResource.java
===================================================================
--- 
src/resources/file/src/java/org/wyona/yanel/impl/resources/node/NodeResource.java   
(Revision 41484)
+++ 
src/resources/file/src/java/org/wyona/yanel/impl/resources/node/NodeResource.java   
(Arbeitskopie)@@ -313,6 +313,11 @@

             if (request instanceof HttpRequest) {
                 HttpRequest yanelRequest = (HttpRequest)request;
+                String maxFileSize = 
getResourceConfigProperty("max-file-upload-size");
+                if (maxFileSize != null) {
+                    // TODO: Implement this method
+                    //yanelRequest.setMaxFileSize(maxFileSize);
+                }
                 if (yanelRequest.isMultipartRequest()) {
                     Enumeration parameters = yanelRequest.getFileNames();
                     if (parameters.hasMoreElements()) {


Index: 
src/webapp/src/java/org/wyona/yanel/servlet/communication/HttpRequest.java
===================================================================
--- 
src/webapp/src/java/org/wyona/yanel/servlet/communication/HttpRequest.java  
(Revision 41484)
+++ 
src/webapp/src/java/org/wyona/yanel/servlet/communication/HttpRequest.java  
(Arbeitskopie)
@@ -60,6 +60,7 @@
                 DiskFileItemFactory factory = new DiskFileItemFactory();

                 // Set factory constraints
+                // TODO: Do not hardcode this size limitation
                 factory.setSizeThreshold(64000);
                 factory.setRepository(new 
File(System.getProperty("java.io.tmpdir")));
                 //Create a new file upload handler


WDYT?

Cheers

Michi


More information about the Yanel-development mailing list