Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 1.6.1
-
Component/s: ICE-Components
-
Labels:None
-
Environment:jsf 1.2, jboss 4.2, windows
-
ICEsoft Forum Reference:
-
Support Case References:
-
Affects:Documentation (User Guide, Ref. Guide, etc.)
Description
There seems to be a bug in apache file upload 1.2 which causes files which are 44 bytes or less to not be uploaded.
44 bytes is the length of the delimiter between parts of the multi-part stream. It seems that if the contents of the file is less than the size of the stream delimiter, then the input stream returns 0 bytes from the stream.
44 bytes is the length of the delimiter between parts of the multi-part stream. It seems that if the contents of the file is less than the size of the stream delimiter, then the input stream returns 0 bytes from the stream.
suggested fix:
Index: D:/Documents and Settings/pbreau/workspace/ICEfaces/component/src/com/icesoft/faces/component/inputfile/InputFile.java
===================================================================
— D:/Documents and Settings/pbreau/workspace/ICEfaces/component/src/com/icesoft/faces/component/inputfile/InputFile.java (revision 15197)
+++ D:/Documents and Settings/pbreau/workspace/ICEfaces/component/src/com/icesoft/faces/component/inputfile/InputFile.java (working copy)
@@ -59,7 +59,7 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.OutputStream;
+import java.io.FileWriter;
import java.io.Serializable;
import java.io.Writer;
import java.util.ArrayList;
@@ -67,6 +67,7 @@
import java.util.Iterator;
+
/**
*/
@@ -195,15 +196,29 @@
if (!folderFile.exists())
folderFile.mkdirs();
file = new File(folder, fileName);
+ FileOutputStream output = new FileOutputStream(file);
+ byte[] buff = new byte[8192];
+ Streams.copy(stream.openStream(), output, true, buff);
+
+ //
ICE-2237workaround for Commons File Upload not properly+ //uploading small files through SSL
+ if (file.length() == 0 && buff[0] != 0)
else if (file.length() == 0)
{ + setProgress(0); + file.delete(); + throw new FileUploadBase.FileUploadIOException( + new FileUploadBase.InvalidContentTypeException()); + }status = SAVED;
fileInfo.setPhysicalPath(file.getAbsolutePath());
updateFileValueBinding(context);
notifyDone(bfc);