Author: joerg
Date: Wed Apr 16 20:32:57 2008
New Revision: 648942
URL: http://svn.apache.org/viewvc?rev=648942&view=rev
Log:
fix inconsistencies between inline parts and file parts when multiple fields of the same name
exist (http://marc.info/?l=xml-cocoon-dev&m=120835513330316&w=4)
Modified:
cocoon/trunk/core/cocoon-core/src/changes/changes.xml
cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/multipart/MultipartParser.java
Modified: cocoon/trunk/core/cocoon-core/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/changes/changes.xml?rev=648942&r1=648941&r2=648942&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/changes/changes.xml (original)
+++ cocoon/trunk/core/cocoon-core/src/changes/changes.xml Wed Apr 16 20:32:57 2008
@@ -29,6 +29,11 @@
<body>
<release version="2.2.0" date="TBA" description="released">
+ <action dev="joerg" type="add">
+ Allow multiple file uploads of the same field name. If there are multiple file uploads
Request.get(String) will
+ return a Vector. If there is only one file upload it will return the Part as it did
before. This is now the same
+ behavior as for inline parts.
+ </action>
<action dev="joerg" type="fix">
Close streams properly after copying Parts (MultipartParser). Allow to access InputStream
of PartInMemory
multiple times.
Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/multipart/MultipartParser.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/multipart/MultipartParser.java?rev=648942&r1=648941&r2=648942&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/multipart/MultipartParser.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/multipart/MultipartParser.java
Wed Apr 16 20:32:57 2008
@@ -323,14 +323,21 @@
if ( out!=null ) out.close();
}
- String name = (String)headers.get("name");
+ String field = (String)headers.get("name");
+ Vector v = (Vector) this.parts.get(field);
+
+ if (v == null) {
+ v = new Vector();
+ this.parts.put(field, v);
+ }
+
if (oversized) {
- this.parts.put(name, new RejectedPart(headers, length, this.contentLength, this.maxUploadSize));
+ v.add(new RejectedPart(headers, length, this.contentLength, this.maxUploadSize));
} else if (file == null) {
byte[] bytes = ((ByteArrayOutputStream) out).toByteArray();
- this.parts.put(name, new PartInMemory(headers, bytes));
+ v.add(new PartInMemory(headers, bytes));
} else {
- this.parts.put(name, new PartOnDisk(headers, file));
+ v.add(new PartOnDisk(headers, file));
}
}
|