vgritsenko 2002/09/21 09:29:34
Modified: src/java/org/apache/cocoon/components/request/multipart
MultipartParser.java
Log:
fix cross-platform upload issues
Revision Changes Path
1.4 +8 -14
xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/MultipartParser.java
Index: MultipartParser.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/MultipartParser.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- MultipartParser.java 23 May 2002 12:01:08 -0000 1.3
+++ MultipartParser.java 21 Sep 2002 16:29:33 -0000 1.4
@@ -179,9 +179,7 @@
throws IOException, MultipartException {
Hashtable headers = new Hashtable();
-
headers = readHeaders(ts);
-
try {
if (headers.containsKey("filename")) {
if (!"".equals(headers.get("filename"))) {
@@ -233,11 +231,14 @@
if (!saveUploadedFilesToDisk) {
out = new ByteArrayOutputStream();
} else {
- String filePath = uploadDirectory.getPath() + File.separator;
-
- String fileName =
- new File((String) headers.get("filename")).getName();
+ String fileName = (String) headers.get("filename");
+ if(File.separatorChar == '\\')
+ fileName = fileName.replace('/','\\');
+ else
+ fileName = fileName.replace('\\','/');
+ String filePath = uploadDirectory.getPath() + File.separator;
+ fileName = new File(fileName).getName();
file = new File(filePath + fileName);
if (file.exists()) {
@@ -259,15 +260,12 @@
}
int read = 0;
-
while (in.getState() == TokenStream.STATE_READING) { // read data
read = in.read(buf);
-
out.write(buf, 0, read);
}
out.close();
-
if (file == null) {
byte[] bytes = ((ByteArrayOutputStream) out).toByteArray();
@@ -295,7 +293,6 @@
while (in.getState() == TokenStream.STATE_READING) {
int read = in.read(buf);
-
value.append(new String(buf, 0, read, this.characterEncoding));
}
@@ -304,7 +301,6 @@
if (v == null) {
v = new Vector();
-
put(field, v);
}
@@ -355,7 +351,6 @@
private String getBoundary(String hdr) {
int start = hdr.toLowerCase().indexOf("boundary=");
-
if (start > -1) {
return "--" + hdr.substring(start + 9);
} else {
@@ -379,7 +374,6 @@
while ((b != -1) && (b != '\r')) {
out.append((char) b);
-
b = in.read();
}
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]