You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2002/09/17 17:56:09 UTC
cvs commit: xml-cocoon2/src/webapp/samples/docs/samples/xsp upload.xsp
vgritsenko 2002/09/17 08:56:09
Modified: . changes.xml
src/java/org/apache/cocoon/components/request/multipart
FilePartArray.java FilePartFile.java
src/webapp/samples/docs/samples/xsp upload.xsp
Log:
improve file upload backward compatibility with 2.0.1
Revision Changes Path
1.251 +5 -1 xml-cocoon2/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/xml-cocoon2/changes.xml,v
retrieving revision 1.250
retrieving revision 1.251
diff -u -r1.250 -r1.251
--- changes.xml 17 Sep 2002 12:07:44 -0000 1.250
+++ changes.xml 17 Sep 2002 15:56:09 -0000 1.251
@@ -40,6 +40,10 @@
</devs>
<release version="@version@" date="@date@">
+ <action dev="VG" type="update">
+ Improve backward compatibility: FilePartFile needs toString() method to
+ work with code written for Cocoon 2.0.
+ </action>
<action dev="SMS" type="update">
Enabled the chaperon text parser as block.
</action>
1.4 +1 -4 xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/FilePartArray.java
Index: FilePartArray.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/FilePartArray.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FilePartArray.java 23 May 2002 12:01:08 -0000 1.3
+++ FilePartArray.java 17 Sep 2002 15:56:09 -0000 1.4
@@ -81,15 +81,12 @@
*
*/
public String getFileName() {
-
File f = new File((String) headers.get("filename"));
-
return f.getName();
}
/**
* Returns a (ByteArray)InputStream containing the file data
- *
*
* @throws Exception
*/
1.4 +9 -5 xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/FilePartFile.java
Index: FilePartFile.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/FilePartFile.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FilePartFile.java 23 May 2002 12:01:08 -0000 1.3
+++ FilePartFile.java 17 Sep 2002 15:56:09 -0000 1.4
@@ -73,13 +73,12 @@
* @param file
*/
protected FilePartFile(Map headers, File file) {
- super(headers);
+ super(headers);
this.file = file;
}
/**
* Returns the filename
- *
*/
public String getFileName() {
return file.getName();
@@ -87,7 +86,6 @@
/**
* Returns the file
- *
*/
public File getFile() {
return file;
@@ -96,10 +94,16 @@
/**
* Returns a (ByteArray)InputStream containing the file data
*
- *
* @throws Exception
*/
public InputStream getInputStream() throws Exception {
return new FileInputStream(file);
+ }
+
+ /**
+ * Returns the filename
+ */
+ public String toString() {
+ return getFileName();
}
}
1.2 +40 -18 xml-cocoon2/src/webapp/samples/docs/samples/xsp/upload.xsp
Index: upload.xsp
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/webapp/samples/docs/samples/xsp/upload.xsp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- upload.xsp 2 Jul 2002 13:06:39 -0000 1.1
+++ upload.xsp 17 Sep 2002 15:56:09 -0000 1.2
@@ -27,31 +27,53 @@
<para>
<form method="post" enctype="multipart/form-data" action="upload">
File: <input type="file" name="uploaded_file" size="50" />
- <p><input type="submit" value="Upload File" /></p>
+ <p>
+ <input type="submit" value="Upload File" />
+ </p>
</form>
</para>
<para>
- <ul>
<xsp:logic>
- getLogger().debug("Dir=" + uploadDir);
- String[] filelist = uploadDir.list();
- <![CDATA[
- getLogger().debug("List=" + filelist.length);
- for (int i = 0; i < filelist.length; i++) {
- getLogger().debug("File [" + i + "]=" + filelist[i]);
- ]]>
- <li>
- <xsp:expr>filelist[i]</xsp:expr>
- </li>
- <![CDATA[
+ if (<xsp-request:get-parameter name="uploaded_file"/> != null) {
+ <xsp:content>
+ Parameter uploaded_file:
+ <strong>
+ <xsp-request:get-parameter name="uploaded_file"/>
+ </strong>
+ <br/>
+
+ Parameter uploaded_file is instance of:
+ <!-- note usage of get() instead of getParameter() -->
+ <strong>
+ <xsp:expr>
+ request.get("uploaded_file").getClass()
+ </xsp:expr>
+ </strong>
+ <br/>
+ </xsp:content>
}
- ]]>
</xsp:logic>
- </ul>
+
+ Upload directory content:
+ <ul>
+ <xsp:logic>
+ getLogger().debug("Dir=" + uploadDir);
+ String[] filelist = uploadDir.list();
+ <![CDATA[
+ getLogger().debug("List=" + filelist.length);
+ for (int i = 0; i < filelist.length; i++) {
+ getLogger().debug("File [" + i + "]=" + filelist[i]);
+ ]]>
+ <li>
+ <xsp:expr>filelist[i]</xsp:expr>
+ </li>
+ <![CDATA[
+ }
+ ]]>
+ </xsp:logic>
+ </ul>
</para>
<para>Brought to you by Cocoon at <xsp:expr>new Date()</xsp:expr>.</para>
-
</content>
</page>
</xsp:page>
-
----------------------------------------------------------------------
In case of troubles, e-mail: webmaster@xml.apache.org
To unsubscribe, e-mail: cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org