Commons FileUpload
  1. Commons FileUpload
  2. FILEUPLOAD-143

"Stream ended unexpectedly" when posting from a Flash client

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2
    • Fix Version/s: 1.3
    • Labels:
      None
    • Environment:

      CentOS 4.4, Jetty running through Red5 (form of Flash Media Server), code under JSP

      Description

      I setup an upload script under a JSP. I tested it by uploading a file via html form upload and it worked fine - the file was received.

      But when I tried uploading the file through a flash interface using the FileReference object I got a 500 error response. Flash's FileReference API was very vague, and I was unable to reproduce the error under another interface so I could see the error.... But I finnally did get something back by writing a catch and writing the error to a file. I don't know if this is accurate or not:

      "Stream ended unexpectedly"

      I do know that the error occurs when this line is ran:

      List items = upload.parseRequest(request);

      And here is some relevant code, but not all of it: (to show that I do have a factory set):

      DiskFileItemFactory factory = new DiskFileItemFactory();
      factory.setSizeThreshold(524288000);
      ServletFileUpload upload = new ServletFileUpload(factory);
      upload.setSizeMax(524288000);
      List items = upload.parseRequest(request);

      I am fairly sure that flash is doing something that is throwing commons-fileupload off. But it does work with apache & php...

      The biggest difference in the headers, or at least the initial headers, is flash passes a "connection: close" header.

      When searching I came up with some vague answers. This page shows some comments at the bottom by users with similar problems:

      http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002225.html

      One guy posts a solution to fix the problem, but it seems like it is severely out of date because where it says "return items;" I do not see items declared in the function of the line he mentions. Plus he mentions line 336, and it's now on 800 something. Tried his suggestion but instead returned "true" and "false" (tried both ways) but it didn't work... Also when I tried his catch line ant said it was invalid, so I had to put "Exception e" instead. You may notice that his post is in all caps (posts after his appear to be for some reason). I did make sure to use the proper case (i do know of case sensitivity).

      With further reading I read instances where flash did a "test upload" without sending the file. In other cases I read something about it not sending to blank lines after the header. Not sure what my current problem is.... I'm sure once the problem is found, it should be fairly trivial to fix (i hope).

      Even though it may be flash's fault, it works in PHP and other instances... So it should work here

      Thanks in advance,

      -Luke

        Activity

        Hide
        Jochen Wiedmann added a comment -

        It's impossible to diagnose the problem without some sort of trace. Such a trace might be created by using tools like tcpmon, or wireshark.

        Show
        Jochen Wiedmann added a comment - It's impossible to diagnose the problem without some sort of trace. Such a trace might be created by using tools like tcpmon, or wireshark.
        Hide
        Luke Scott added a comment -

        Other than the information I've given you, I have no idea how to do that because of my lack of experience. I know that it does work with a standard html upload, just not the flash... I'm trying to get the complete body of the post, but I'm not sure how to do that with java. I got the error message through e.getMessage() in a catch statement. Flash doesn't give me the whole response. I'll be happy to get you more information, but I may need some assistance in getting it .

        Show
        Luke Scott added a comment - Other than the information I've given you, I have no idea how to do that because of my lack of experience. I know that it does work with a standard html upload, just not the flash... I'm trying to get the complete body of the post, but I'm not sure how to do that with java. I got the error message through e.getMessage() in a catch statement. Flash doesn't give me the whole response. I'll be happy to get you more information, but I may need some assistance in getting it .
        Hide
        Luke Scott added a comment -

        Finnally figured out how to get a stack trace. Here it is:

        org.apache.commons.fileupload.FileUploadException: Stream ended unexpectedly
        at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:369)
        at org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:126)
        at org.apache.jsp.index_jsp._jspService(index_jsp.java:84)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:491)
        at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:367)
        at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:185)
        at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
        at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:689)
        at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:391)
        at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:146)
        at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
        at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
        at org.mortbay.jetty.Server.handle(Server.java:285)
        at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:457)
        at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:765)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:627)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:203)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:357)
        at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:329)
        at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:475)
        Caused by:
        org.apache.commons.fileupload.MultipartStream$MalformedStreamException: Stream ended unexpectedly
        at org.apache.commons.fileupload.MultipartStream.readHeaders(MultipartStream.java:542)
        at org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.findNextItem(FileUploadBase.java:859)
        at org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.hasNext(FileUploadBase.java:916)
        at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:348)
        at org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:126)
        at org.apache.jsp.index_jsp._jspService(index_jsp.java:84)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:491)
        at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:367)
        at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:185)
        at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
        at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:689)
        at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:391)
        at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:146)
        at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
        at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
        at org.mortbay.jetty.Server.handle(Server.java:285)
        at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:457)
        at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:765)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:627)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:203)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:357)
        at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:329)
        at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:475)

        Show
        Luke Scott added a comment - Finnally figured out how to get a stack trace. Here it is: org.apache.commons.fileupload.FileUploadException: Stream ended unexpectedly at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:369) at org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:126) at org.apache.jsp.index_jsp._jspService(index_jsp.java:84) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:491) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:367) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:185) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:689) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:391) at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:146) at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139) at org.mortbay.jetty.Server.handle(Server.java:285) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:457) at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:765) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:627) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:203) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:357) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:329) at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:475) Caused by: org.apache.commons.fileupload.MultipartStream$MalformedStreamException: Stream ended unexpectedly at org.apache.commons.fileupload.MultipartStream.readHeaders(MultipartStream.java:542) at org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.findNextItem(FileUploadBase.java:859) at org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.hasNext(FileUploadBase.java:916) at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:348) at org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:126) at org.apache.jsp.index_jsp._jspService(index_jsp.java:84) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:491) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:367) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:185) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:689) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:391) at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:146) at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139) at org.mortbay.jetty.Server.handle(Server.java:285) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:457) at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:765) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:627) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:203) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:357) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:329) at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:475)
        Hide
        Jochen Wiedmann added a comment -

        That's not the trace I was thinking of. The stack trace only demonstrates, that commons fileupload believes that the input stream terminates prematurely. In other words, that the input stream is corrupt.

        My guess would be that the library is right and that, for example, the network connection broke or something similar. However, it is also possible that there's a bug in the library. To diagnose that, I'd need a trace of the data, which the browser has sent. Such a trace can easily be obtained with tools like tcpmon or wireshark.

        Show
        Jochen Wiedmann added a comment - That's not the trace I was thinking of. The stack trace only demonstrates, that commons fileupload believes that the input stream terminates prematurely. In other words, that the input stream is corrupt. My guess would be that the library is right and that, for example, the network connection broke or something similar. However, it is also possible that there's a bug in the library. To diagnose that, I'd need a trace of the data, which the browser has sent. Such a trace can easily be obtained with tools like tcpmon or wireshark.
        Hide
        Luke Scott added a comment -

        I'm fairly sure I figured out what's causing this. It turns out Flash 8 (not sure about 9) doesn't properly terminate the final boundary. The final boundary should end with a "--", but it doesn't. Because of this, commons-fileupload is throwing an exception.

        Other interfaces like PHP catch the error, but allows the file to be uploaded anyway. Somehow commons-fileupload needs to do the same thing.

        Here are the headers, minus the data for obvious reasons:

        POST /index.html HTTP/1.1
        Connection: close
        User-Agent: Macromedia Flash Player 8
        X-Flash-Version: 8,0,22,0
        Accept-Types: text/*
        Content-Type: multipart/form-data; boundary=----------gL6Ij5ei4gL6Ef1GI3gL6gL6KM7cH2
        Content-Length: 35122482
        Host: localhost:4242

        ------------gL6Ij5ei4gL6Ef1GI3gL6gL6KM7cH2
        Content-Disposition: form-data; name="Filename"

        arewethereyet.mov
        ------------gL6Ij5ei4gL6Ef1GI3gL6gL6KM7cH2
        Content-Disposition: form-data; name="Filedata"; filename="arewethereyet.mov"
        Content-Type: application/octet-stream

        ...DATA HERE...
        ------------gL6Ij5ei4gL6Ef1GI3gL6gL6KM7cH2
        Content-Disposition: form-data; name="Upload"
        Submit Query
        ------------gL6Ij5ei4gL6Ef1GI3gL6gL6KM7cH2

        Show
        Luke Scott added a comment - I'm fairly sure I figured out what's causing this. It turns out Flash 8 (not sure about 9) doesn't properly terminate the final boundary. The final boundary should end with a "--", but it doesn't. Because of this, commons-fileupload is throwing an exception. Other interfaces like PHP catch the error, but allows the file to be uploaded anyway. Somehow commons-fileupload needs to do the same thing. Here are the headers, minus the data for obvious reasons: POST /index.html HTTP/1.1 Connection: close User-Agent: Macromedia Flash Player 8 X-Flash-Version: 8,0,22,0 Accept-Types: text/* Content-Type: multipart/form-data; boundary=----------gL6Ij5ei4gL6Ef1GI3gL6gL6KM7cH2 Content-Length: 35122482 Host: localhost:4242 ------------gL6Ij5ei4gL6Ef1GI3gL6gL6KM7cH2 Content-Disposition: form-data; name="Filename" arewethereyet.mov ------------gL6Ij5ei4gL6Ef1GI3gL6gL6KM7cH2 Content-Disposition: form-data; name="Filedata"; filename="arewethereyet.mov" Content-Type: application/octet-stream ...DATA HERE... ------------gL6Ij5ei4gL6Ef1GI3gL6gL6KM7cH2 Content-Disposition: form-data; name="Upload" Submit Query ------------gL6Ij5ei4gL6Ef1GI3gL6gL6KM7cH2
        Hide
        Jochen Wiedmann added a comment -

        Unsure, whether this works, but you might try to use the streaming API. If you are lucky, you'll get all the items and can read them until you finally encounter the exception.

        Show
        Jochen Wiedmann added a comment - Unsure, whether this works, but you might try to use the streaming API. If you are lucky, you'll get all the items and can read them until you finally encounter the exception.
        Hide
        Jochen Wiedmann added a comment -

        I notice, that my suggestion is consistent with the following quote from

        http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002225.html

        AJKERR SAID ON JAN 11, 2006 AT 12:34 PM :

        IN ORDER TO GET FILE UPLOADING TO WORK WITH FLASH PLAYER 8 AND JAKARTA COMMONS FILE UPLOAD ON THE SERVER, WE HAD TO PATCH THE FILE UPLOAD SERVER CODE TO IGNORE THE EXCEPTION THAT WAS (CORRECTLY) BEING THROWN ON THE SERVER WHEN THE LAST SECTION IS PROCESSED.

        THE CLASS THAT NEEDS TO BE PATCHED IS ORG.APACHE.COMMONS.FILEUPLOAD.FILEUPLOADBASE.

        YOU'LL NEED TO REPLACE LINE 336:
        MAP HEADERS = PARSEHEADERS(MULTI.READHEADERS());

        ...WITH THE FOLLOWING CODE:
        MAP HEADERS = NULL;
        TRY

        { HEADERS = PARSEHEADERS(MULTI.READHEADERS()); }

        CATCH (MULTIPARTSTREAM.MALFORMEDSTREAMEXCEPTION E)

        { RETURN ITEMS; }

        NOT THE MOST ELEGANT FIX, BUT IT WORKS AS A STOPGAP UNTIL MACROMEDIA RELEASES AN UPDATE TO THE FLASH 8 PLAYER.

        Show
        Jochen Wiedmann added a comment - I notice, that my suggestion is consistent with the following quote from http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002225.html AJKERR SAID ON JAN 11, 2006 AT 12:34 PM : IN ORDER TO GET FILE UPLOADING TO WORK WITH FLASH PLAYER 8 AND JAKARTA COMMONS FILE UPLOAD ON THE SERVER, WE HAD TO PATCH THE FILE UPLOAD SERVER CODE TO IGNORE THE EXCEPTION THAT WAS (CORRECTLY) BEING THROWN ON THE SERVER WHEN THE LAST SECTION IS PROCESSED. THE CLASS THAT NEEDS TO BE PATCHED IS ORG.APACHE.COMMONS.FILEUPLOAD.FILEUPLOADBASE. YOU'LL NEED TO REPLACE LINE 336: MAP HEADERS = PARSEHEADERS(MULTI.READHEADERS()); ...WITH THE FOLLOWING CODE: MAP HEADERS = NULL; TRY { HEADERS = PARSEHEADERS(MULTI.READHEADERS()); } CATCH (MULTIPARTSTREAM.MALFORMEDSTREAMEXCEPTION E) { RETURN ITEMS; } NOT THE MOST ELEGANT FIX, BUT IT WORKS AS A STOPGAP UNTIL MACROMEDIA RELEASES AN UPDATE TO THE FLASH 8 PLAYER.
        Hide
        Luke Scott added a comment -

        For some reason that solution did not work for me. I've tried it before.

        I'm attempting to use the streaming method, but I am unclear how to write the file using this method.

        My other concern is, what if the file being uploaded is large?

        Show
        Luke Scott added a comment - For some reason that solution did not work for me. I've tried it before. I'm attempting to use the streaming method, but I am unclear how to write the file using this method. My other concern is, what if the file being uploaded is large?
        Hide
        Luke Scott added a comment -

        Well I got a standard upload to work with the streaming API finally, just like it was working for the standard method. Then when I attempted to upload the file via flash, it gives me an "HTTP error" invoked by "onIOError".... This event doesn't return any error codes at all, so now I don't have any idea what's causing it to not work.

        Show
        Luke Scott added a comment - Well I got a standard upload to work with the streaming API finally, just like it was working for the standard method. Then when I attempted to upload the file via flash, it gives me an "HTTP error" invoked by "onIOError".... This event doesn't return any error codes at all, so now I don't have any idea what's causing it to not work.
        Hide
        Luke Scott added a comment -

        Oh now I feel silly.. I had the wrong URL put into my flash app... Now it works, but it still throws the exception. At least I got the file to save this time .

        The guide needs to be updated... The regular interface has an example of how to write a file, but the Streaming API does not. The regular interface talks about streaming data, which could easily be confused with the streaming APi... They don't mean the same thing.

        With the right libraries included, this is my final code that works. It also takes into account certain flash plugins sending a "test". I have yet to come across that, but it's better to be safe than sorry.

        if( request.getContentLength() > 0 )
        {
        Boolean isMultipart = ServletFileUpload.isMultipartContent(request);

        if( isMultipart )
        {
        ServletFileUpload upload = new ServletFileUpload();
        FileItemIterator iter = upload.getItemIterator(request);
        while( iter.hasNext() )
        {
        try
        {
        FileItemStream item = iter.next();
        InputStream stream = item.openStream();

        if( !item.isFormField() && item.getFieldName().equals("Filedata") )

        { OutputStream outstream = new FileOutputStream("/opt/red5/webapps/test/uploaded/" + item.getName()); Streams.copy(stream,outstream,true); }

        }
        }
        }
        }

        Question: Should I close input and output stream in a finally block? Is there anything else I'm missing?

        Show
        Luke Scott added a comment - Oh now I feel silly.. I had the wrong URL put into my flash app... Now it works, but it still throws the exception. At least I got the file to save this time . The guide needs to be updated... The regular interface has an example of how to write a file, but the Streaming API does not. The regular interface talks about streaming data, which could easily be confused with the streaming APi... They don't mean the same thing. With the right libraries included, this is my final code that works. It also takes into account certain flash plugins sending a "test". I have yet to come across that, but it's better to be safe than sorry. if( request.getContentLength() > 0 ) { Boolean isMultipart = ServletFileUpload.isMultipartContent(request); if( isMultipart ) { ServletFileUpload upload = new ServletFileUpload(); FileItemIterator iter = upload.getItemIterator(request); while( iter.hasNext() ) { try { FileItemStream item = iter.next(); InputStream stream = item.openStream(); if( !item.isFormField() && item.getFieldName().equals("Filedata") ) { OutputStream outstream = new FileOutputStream("/opt/red5/webapps/test/uploaded/" + item.getName()); Streams.copy(stream,outstream,true); } } } } } Question: Should I close input and output stream in a finally block? Is there anything else I'm missing?
        Hide
        Jochen Wiedmann added a comment -

        I have added the following entry to the FAQ:

        <part id="flash">
        <title>FileUpload and Flash</title>
        <faq id="missing-boundary-terminator">
        <question>
        I'm using FileUpload to receive an upload from flash, but
        FileUpload will always throw an Exception "Stream ended unexpectedly".
        What can I do?
        </question>
        <answer>
        <p>
        At least as of version 8, Flash contains a known bug: The multipart
        stream it produces is broken, because the final boundary doesn't
        contain the suffix "--", which ought to indicate, that no more
        items are following. Consequently, FileUpload waits for the next
        item (which it doesn't get) and throws an exception.
        </p>
        <p>
        The problems details and a possible workaround are outlined in
        <a href="http://issues.apache.org/jira/browse/FILEUPLOAD-143">
        Bug 143</a>. The workaround suggests to use the streaming API
        and catch the exception. The resulting code could look like
        this:
        </p>
        <pre>
        List items = new ArrayList();
        FileItemIterator iter = fileUploadBase.getItemIterator(ctx);
        try {
        while (iter.hasNext())

        { FileItemStream item = iter.next(); FileItem fileItem = fileItemFactory.createItem(item.getFieldName(), item.getContentType(), item.isFormField(), item.getName()); Streams.copy(item.openStream(), fileItem.getOutputStream(), true); items.add(fileItem); }

        } catch (MalformedStreamException e)

        { // Ignore this }

        </pre>
        </answer>
        </faq>
        </part>

        Show
        Jochen Wiedmann added a comment - I have added the following entry to the FAQ: <part id="flash"> <title>FileUpload and Flash</title> <faq id="missing-boundary-terminator"> <question> I'm using FileUpload to receive an upload from flash, but FileUpload will always throw an Exception "Stream ended unexpectedly". What can I do? </question> <answer> <p> At least as of version 8, Flash contains a known bug: The multipart stream it produces is broken, because the final boundary doesn't contain the suffix "--", which ought to indicate, that no more items are following. Consequently, FileUpload waits for the next item (which it doesn't get) and throws an exception. </p> <p> The problems details and a possible workaround are outlined in <a href="http://issues.apache.org/jira/browse/FILEUPLOAD-143"> Bug 143</a>. The workaround suggests to use the streaming API and catch the exception. The resulting code could look like this: </p> <pre> List items = new ArrayList(); FileItemIterator iter = fileUploadBase.getItemIterator(ctx); try { while (iter.hasNext()) { FileItemStream item = iter.next(); FileItem fileItem = fileItemFactory.createItem(item.getFieldName(), item.getContentType(), item.isFormField(), item.getName()); Streams.copy(item.openStream(), fileItem.getOutputStream(), true); items.add(fileItem); } } catch (MalformedStreamException e) { // Ignore this } </pre> </answer> </faq> </part>
        Hide
        Luke Scott added a comment -

        "ctx" is not defined. Plus, I think the try block needs to be around iterator as well. And just in case I think the input stream needs to be closed with the finally block. I've also included a fix where some flash versions will send a 0 byte test. Here is my final code:

        if( request.getContentLength() > 0 )
        {
        Boolean isMultipart = ServletFileUpload.isMultipartContent(request);

        if( isMultipart )
        {
        try
        {
        ServletFileUpload upload = new ServletFileUpload();
        FileItemIterator iter = upload.getItemIterator(request);
        while( iter.hasNext() )
        {
        FileItemStream item = iter.next();
        InputStream stream = item.openStream();

        if( !item.isFormField() && item.getFieldName().equals("Filedata") )

        { String filename = item.getName(); String tmpPath = "/opt/red5/webapps/test/uploaded/.tmp." + filename; String finPath = "/opt/red5/webapps/test/uploaded/" + filename; OutputStream outstream = new FileOutputStream( tmpPath ); Streams.copy(stream,outstream,true); File tmpFile = File( tmpPath ); File finFile = File( finPath ); tmpFile.renameTo( finFile ); }

        }
        }
        catch( Exception e ) { }
        finally

        { stream.close(); }

        }
        }

        Show
        Luke Scott added a comment - "ctx" is not defined. Plus, I think the try block needs to be around iterator as well. And just in case I think the input stream needs to be closed with the finally block. I've also included a fix where some flash versions will send a 0 byte test. Here is my final code: if( request.getContentLength() > 0 ) { Boolean isMultipart = ServletFileUpload.isMultipartContent(request); if( isMultipart ) { try { ServletFileUpload upload = new ServletFileUpload(); FileItemIterator iter = upload.getItemIterator(request); while( iter.hasNext() ) { FileItemStream item = iter.next(); InputStream stream = item.openStream(); if( !item.isFormField() && item.getFieldName().equals("Filedata") ) { String filename = item.getName(); String tmpPath = "/opt/red5/webapps/test/uploaded/.tmp." + filename; String finPath = "/opt/red5/webapps/test/uploaded/" + filename; OutputStream outstream = new FileOutputStream( tmpPath ); Streams.copy(stream,outstream,true); File tmpFile = File( tmpPath ); File finFile = File( finPath ); tmpFile.renameTo( finFile ); } } } catch( Exception e ) { } finally { stream.close(); } } }
        Hide
        Jon Poulton added a comment - - edited

        I've been getting a similar error. The stack trace for us, is as follows:

        2010-07-19 17:30:14,887 [TP-Processor7] ERROR vyre.publishing.portal.PortalFramework - Could not render portlet vyre.publishing.PortletInstance_628#46
        org.exoplatform.services.portletcontainer.PortletProcessingException:
        at org.exoplatform.services.portletcontainer.plugins.pc.PortletApplicationHandler.processPortletException(PortletApplicationHandler.java:395)
        at org.exoplatform.services.portletcontainer.plugins.pc.PortletApplicationHandler.process(PortletApplicationHandler.java:333)
        at org.exoplatform.services.portletcontainer.impl.servlet.ServletWrapper.service(ServletWrapper.java:139)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)
        at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:535)
        at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:472)
        at org.exoplatform.services.portletcontainer.plugins.pc.PortletContainerDispatcher.dispatch(PortletContainerDispatcher.java:895)
        at org.exoplatform.services.portletcontainer.plugins.pc.PortletContainerDispatcher.process(PortletContainerDispatcher.java:818)
        at org.exoplatform.services.portletcontainer.plugins.pc.PortletContainerDispatcher.render(PortletContainerDispatcher.java:708)
        at org.exoplatform.services.portletcontainer.impl.PortletContainerServiceImpl.render(PortletContainerServiceImpl.java:569)
        at vyre.publishing.portal.PortalFramework.render(PortalFramework.java:751)
        at vyre.publishing.portal.PortalFramework.renderPortlet(PortalFramework.java:944)
        at vyre.publishing.PortletInstance.render(PortletInstance.java:259)
        at sun.reflect.GeneratedMethodAccessor405.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:157)
        at vyre.publishing.PortletInstance$$EnhancerByCGLIB$$4a6f6a50.render(<generated>)
        at org.apache.jsp.WEB_002dINF.jsp.pub_005fmodule.portlet.portlet_005frender_jsp._jspService(Unknown Source)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)
        at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:535)
        at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:472)
        at vyre.publishing.ContentArea.render(ContentArea.java:352)
        at org.apache.jsp.WEB_002dINF.jsp.pub_005fmodule.portlet.content_005farea_005frender_jsp._jspService(Unknown Source)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)
        at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:535)
        at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:472)
        at vyre.publishing.taglibs.ContentAreaTag.doStartTag(ContentAreaTag.java:64)
        at org.apache.jsp.WEB_002dINF.generated_005ffiles.pub_005fmodule.template.t47_005f23_jsp._jspx_meth_vyre_002dtemplate_005fcontent_002darea_005f0(t47_005f23_jsp.java:356)
        at org.apache.jsp.WEB_002dINF.generated_005ffiles.pub_005fmodule.template.t47_005f23_jsp._jspService(t47_005f23_jsp.java:110)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)
        at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
        at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
        at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
        at vyre.publishing.PathFilter.doFilter(PathFilter.java:240)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at vyre.content.search.permissions.ViewPermissionFilter.doFilter(ViewPermissionFilter.java:27)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at vyre.realms.GateKeeper.doFilter(GateKeeper.java:137)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
        at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
        at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
        at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697)
        at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
        at java.lang.Thread.run(Thread.java:619)
        Caused by: javax.portlet.PortletException: Request processing failed
        at org.springframework.web.portlet.FrameworkPortlet.processRequest(FrameworkPortlet.java:496)
        at org.springframework.web.portlet.FrameworkPortlet.doDispatch(FrameworkPortlet.java:453)
        at javax.portlet.GenericPortlet.render(GenericPortlet.java:233)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.PortletMethodCommand.render(PortletMethodCommand.java:62)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:46)
        at org.exoplatform.container.component.ExecutionContext.executeNextUnit(ExecutionContext.java:39)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.render(BaseCommandUnit.java:66)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.PortletSessionValidationCommand.render(PortletSessionValidationCommand.java:16)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:46)
        at org.exoplatform.container.component.ExecutionContext.executeNextUnit(ExecutionContext.java:39)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.PortletContentCommand.render(PortletContentCommand.java:28)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:46)
        at org.exoplatform.container.component.ExecutionContext.executeNextUnit(ExecutionContext.java:39)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.PortletCacheCommand.render(PortletCacheCommand.java:109)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:46)
        at org.exoplatform.container.component.ExecutionContext.executeNextUnit(ExecutionContext.java:39)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.PortletFilterCommand.render(PortletFilterCommand.java:71)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:46)
        at org.exoplatform.container.component.ExecutionContext.executeNextUnit(ExecutionContext.java:39)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.PortletSecurityCommand.render(PortletSecurityCommand.java:49)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:46)
        at org.exoplatform.container.component.ExecutionContext.executeNextUnit(ExecutionContext.java:39)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.render(BaseCommandUnit.java:66)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:46)
        at org.exoplatform.container.component.ExecutionContext.execute(ExecutionContext.java:32)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.PortletCommandChain.doRender(PortletCommandChain.java:61)
        at org.exoplatform.services.portletcontainer.plugins.pc.PortletApplicationHandler.process(PortletApplicationHandler.java:300)
        ... 77 more
        Caused by: java.lang.RuntimeException: org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. null
        at vyre.util.params.PortletForm.getMap(PortletForm.java:109)
        at vyre.util.params.PortletForm.<init>(PortletForm.java:28)
        at vyre.util.params.ParameterManager.getParameters(ParameterManager.java:48)
        at vyre.portlets.items.templateEdit.ViewController.handleActionRequestInternal(ViewController.java:105)
        at vyre.portlets.items.templateEdit.ViewController.handleActionRequestInternal(ViewController.java:99)
        at org.springframework.web.portlet.mvc.AbstractController.handleActionRequest(AbstractController.java:196)
        at org.springframework.web.portlet.mvc.SimpleControllerHandlerAdapter.handleAction(SimpleControllerHandlerAdapter.java:46)
        at org.springframework.web.portlet.DispatcherPortlet.doActionService(DispatcherPortlet.java:694)
        at org.springframework.web.portlet.FrameworkPortlet.processRequest(FrameworkPortlet.java:480)
        at org.springframework.web.portlet.FrameworkPortlet.processAction(FrameworkPortlet.java:462)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.PortletMethodCommand.processAction(PortletMethodCommand.java:89)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:57)
        at org.exoplatform.container.component.ExecutionContext.executeNextUnit(ExecutionContext.java:39)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.processAction(BaseCommandUnit.java:93)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:57)
        at org.exoplatform.container.component.ExecutionContext.executeNextUnit(ExecutionContext.java:39)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.processAction(BaseCommandUnit.java:93)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:57)
        at org.exoplatform.container.component.ExecutionContext.executeNextUnit(ExecutionContext.java:39)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.PortletCacheCommand.processAction(PortletCacheCommand.java:288)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:57)
        at org.exoplatform.container.component.ExecutionContext.executeNextUnit(ExecutionContext.java:39)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.PortletFilterCommand.processAction(PortletFilterCommand.java:108)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:57)
        at org.exoplatform.container.component.ExecutionContext.executeNextUnit(ExecutionContext.java:39)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.PortletSecurityCommand.processAction(PortletSecurityCommand.java:68)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:57)
        at org.exoplatform.container.component.ExecutionContext.executeNextUnit(ExecutionContext.java:39)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.processAction(BaseCommandUnit.java:93)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:57)
        at org.exoplatform.container.component.ExecutionContext.execute(ExecutionContext.java:32)
        at org.exoplatform.services.portletcontainer.plugins.pc.aop.PortletCommandChain.doProcessAction(PortletCommandChain.java:75)
        at org.exoplatform.services.portletcontainer.plugins.pc.PortletApplicationHandler.process(PortletApplicationHandler.java:284)
        at org.exoplatform.services.portletcontainer.impl.servlet.ServletWrapper.service(ServletWrapper.java:139)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)
        at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:535)
        at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:472)
        at org.exoplatform.services.portletcontainer.plugins.pc.PortletContainerDispatcher.dispatch(PortletContainerDispatcher.java:895)
        at org.exoplatform.services.portletcontainer.plugins.pc.PortletContainerDispatcher.process(PortletContainerDispatcher.java:818)
        at org.exoplatform.services.portletcontainer.plugins.pc.PortletContainerDispatcher.processAction(PortletContainerDispatcher.java:670)
        at org.exoplatform.services.portletcontainer.impl.PortletContainerServiceImpl.processAction(PortletContainerServiceImpl.java:509)
        at vyre.publishing.portal.PortalFramework.processAction(PortalFramework.java:684)
        at vyre.publishing.portal.PortalFramework.preRenderProcessing(PortalFramework.java:893)
        at vyre.publishing.deployment.PageGenerator.prepareForRender(PageGenerator.java:328)
        at vyre.publishing.deployment.PageGenerator.prepareForRender(PageGenerator.java:211)
        at vyre.publishing.deployment.PageGenerator.prepareForRender(PageGenerator.java:200)
        at vyre.publishing.PathFilter.doFilter(PathFilter.java:193)
        ... 25 more
        Caused by: org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. null
        at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:367)
        at org.apache.commons.fileupload.portlet.PortletFileUpload.parseRequest(PortletFileUpload.java:119)
        at vyre.util.params.PortletForm.getMap(PortletForm.java:69)
        ... 74 more
        Caused by: java.io.IOException
        at org.apache.jk.common.JkInputStream.receive(JkInputStream.java:199)
        at org.apache.jk.common.JkInputStream.refillReadBuffer(JkInputStream.java:258)
        at org.apache.jk.common.JkInputStream.doRead(JkInputStream.java:177)
        at org.apache.coyote.Request.doRead(Request.java:428)
        at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:304)
        at org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:405)
        at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:327)
        at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:193)
        at org.apache.commons.fileupload.MultipartStream$ItemInputStream.makeAvailable(MultipartStream.java:977)
        at org.apache.commons.fileupload.MultipartStream$ItemInputStream.read(MultipartStream.java:887)
        at java.io.InputStream.read(InputStream.java:85)
        at org.apache.commons.fileupload.util.Streams.copy(Streams.java:94)
        at org.apache.commons.fileupload.util.Streams.copy(Streams.java:64)
        at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:362)
        ... 76 more

        This happens regularly with very large files.

        MultipartStream appears to be causing problems here. The code that throws the Exception is as follows:

        lines 963 through 1006 in release 1.2.1

        MultipartStream.java
               private int makeAvailable() throws IOException {
                    if (pos != -1) {
                        return 0;
                    }
        
                    // Move the data to the beginning of the buffer.
                    total += tail - head - pad;
                    System.arraycopy(buffer, tail - pad, buffer, 0, pad);
        
                    // Refill buffer with new data.
                    head = 0;
                    tail = pad;
        
                    for ( ; ; ) {
                        int bytesRead = input.read(buffer, tail, bufSize - tail);
                        if (bytesRead == -1) {
                            // The last pad amount is left in the buffer.
                            // Boundary can't be in there so signal an error
                            // condition.
                            final String msg = "Stream ended unexpectedly";
                            throw new MalformedStreamException(msg);
                        }
                        if (notifier != null) {
                            notifier.noteBytesRead(bytesRead);
                        }
                        tail += bytesRead;
        
                        findSeparator();
                        int av = available();
        
                        if (av > 0 || pos != -1) {
                            return av;
                        }
                    }
                }
        

        When input.read() is called it returns -1 indicating that there is no more data to be read. For some reason this is considered to be an error, and an Exception is thrown.

        I've had a look at previous versions of FileUpload, and more or less the same thing has been done for a while. I was wondering if anyone could explain to me why an Exception is thrown in this instance?

        References

        http://commons.apache.org/fileupload/apidocs/org/apache/commons/fileupload/MultipartStream.html
        http://java.sun.com/javase/6/docs/api/java/io/InputStream.html

        Show
        Jon Poulton added a comment - - edited I've been getting a similar error. The stack trace for us, is as follows: 2010-07-19 17:30:14,887 [TP-Processor7] ERROR vyre.publishing.portal.PortalFramework - Could not render portlet vyre.publishing.PortletInstance_628#46 org.exoplatform.services.portletcontainer.PortletProcessingException: at org.exoplatform.services.portletcontainer.plugins.pc.PortletApplicationHandler.processPortletException(PortletApplicationHandler.java:395) at org.exoplatform.services.portletcontainer.plugins.pc.PortletApplicationHandler.process(PortletApplicationHandler.java:333) at org.exoplatform.services.portletcontainer.impl.servlet.ServletWrapper.service(ServletWrapper.java:139) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:535) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:472) at org.exoplatform.services.portletcontainer.plugins.pc.PortletContainerDispatcher.dispatch(PortletContainerDispatcher.java:895) at org.exoplatform.services.portletcontainer.plugins.pc.PortletContainerDispatcher.process(PortletContainerDispatcher.java:818) at org.exoplatform.services.portletcontainer.plugins.pc.PortletContainerDispatcher.render(PortletContainerDispatcher.java:708) at org.exoplatform.services.portletcontainer.impl.PortletContainerServiceImpl.render(PortletContainerServiceImpl.java:569) at vyre.publishing.portal.PortalFramework.render(PortalFramework.java:751) at vyre.publishing.portal.PortalFramework.renderPortlet(PortalFramework.java:944) at vyre.publishing.PortletInstance.render(PortletInstance.java:259) at sun.reflect.GeneratedMethodAccessor405.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:157) at vyre.publishing.PortletInstance$$EnhancerByCGLIB$$4a6f6a50.render(<generated>) at org.apache.jsp.WEB_002dINF.jsp.pub_005fmodule.portlet.portlet_005frender_jsp._jspService(Unknown Source) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:535) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:472) at vyre.publishing.ContentArea.render(ContentArea.java:352) at org.apache.jsp.WEB_002dINF.jsp.pub_005fmodule.portlet.content_005farea_005frender_jsp._jspService(Unknown Source) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:535) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:472) at vyre.publishing.taglibs.ContentAreaTag.doStartTag(ContentAreaTag.java:64) at org.apache.jsp.WEB_002dINF.generated_005ffiles.pub_005fmodule.template.t47_005f23_jsp._jspx_meth_vyre_002dtemplate_005fcontent_002darea_005f0(t47_005f23_jsp.java:356) at org.apache.jsp.WEB_002dINF.generated_005ffiles.pub_005fmodule.template.t47_005f23_jsp._jspService(t47_005f23_jsp.java:110) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302) at vyre.publishing.PathFilter.doFilter(PathFilter.java:240) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at vyre.content.search.permissions.ViewPermissionFilter.doFilter(ViewPermissionFilter.java:27) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at vyre.realms.GateKeeper.doFilter(GateKeeper.java:137) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190) at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283) at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767) at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697) at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690) at java.lang.Thread.run(Thread.java:619) Caused by: javax.portlet.PortletException: Request processing failed at org.springframework.web.portlet.FrameworkPortlet.processRequest(FrameworkPortlet.java:496) at org.springframework.web.portlet.FrameworkPortlet.doDispatch(FrameworkPortlet.java:453) at javax.portlet.GenericPortlet.render(GenericPortlet.java:233) at org.exoplatform.services.portletcontainer.plugins.pc.aop.PortletMethodCommand.render(PortletMethodCommand.java:62) at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:46) at org.exoplatform.container.component.ExecutionContext.executeNextUnit(ExecutionContext.java:39) at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.render(BaseCommandUnit.java:66) at org.exoplatform.services.portletcontainer.plugins.pc.aop.PortletSessionValidationCommand.render(PortletSessionValidationCommand.java:16) at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:46) at org.exoplatform.container.component.ExecutionContext.executeNextUnit(ExecutionContext.java:39) at org.exoplatform.services.portletcontainer.plugins.pc.aop.PortletContentCommand.render(PortletContentCommand.java:28) at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:46) at org.exoplatform.container.component.ExecutionContext.executeNextUnit(ExecutionContext.java:39) at org.exoplatform.services.portletcontainer.plugins.pc.aop.PortletCacheCommand.render(PortletCacheCommand.java:109) at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:46) at org.exoplatform.container.component.ExecutionContext.executeNextUnit(ExecutionContext.java:39) at org.exoplatform.services.portletcontainer.plugins.pc.aop.PortletFilterCommand.render(PortletFilterCommand.java:71) at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:46) at org.exoplatform.container.component.ExecutionContext.executeNextUnit(ExecutionContext.java:39) at org.exoplatform.services.portletcontainer.plugins.pc.aop.PortletSecurityCommand.render(PortletSecurityCommand.java:49) at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:46) at org.exoplatform.container.component.ExecutionContext.executeNextUnit(ExecutionContext.java:39) at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.render(BaseCommandUnit.java:66) at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:46) at org.exoplatform.container.component.ExecutionContext.execute(ExecutionContext.java:32) at org.exoplatform.services.portletcontainer.plugins.pc.aop.PortletCommandChain.doRender(PortletCommandChain.java:61) at org.exoplatform.services.portletcontainer.plugins.pc.PortletApplicationHandler.process(PortletApplicationHandler.java:300) ... 77 more Caused by: java.lang.RuntimeException: org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. null at vyre.util.params.PortletForm.getMap(PortletForm.java:109) at vyre.util.params.PortletForm.<init>(PortletForm.java:28) at vyre.util.params.ParameterManager.getParameters(ParameterManager.java:48) at vyre.portlets.items.templateEdit.ViewController.handleActionRequestInternal(ViewController.java:105) at vyre.portlets.items.templateEdit.ViewController.handleActionRequestInternal(ViewController.java:99) at org.springframework.web.portlet.mvc.AbstractController.handleActionRequest(AbstractController.java:196) at org.springframework.web.portlet.mvc.SimpleControllerHandlerAdapter.handleAction(SimpleControllerHandlerAdapter.java:46) at org.springframework.web.portlet.DispatcherPortlet.doActionService(DispatcherPortlet.java:694) at org.springframework.web.portlet.FrameworkPortlet.processRequest(FrameworkPortlet.java:480) at org.springframework.web.portlet.FrameworkPortlet.processAction(FrameworkPortlet.java:462) at org.exoplatform.services.portletcontainer.plugins.pc.aop.PortletMethodCommand.processAction(PortletMethodCommand.java:89) at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:57) at org.exoplatform.container.component.ExecutionContext.executeNextUnit(ExecutionContext.java:39) at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.processAction(BaseCommandUnit.java:93) at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:57) at org.exoplatform.container.component.ExecutionContext.executeNextUnit(ExecutionContext.java:39) at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.processAction(BaseCommandUnit.java:93) at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:57) at org.exoplatform.container.component.ExecutionContext.executeNextUnit(ExecutionContext.java:39) at org.exoplatform.services.portletcontainer.plugins.pc.aop.PortletCacheCommand.processAction(PortletCacheCommand.java:288) at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:57) at org.exoplatform.container.component.ExecutionContext.executeNextUnit(ExecutionContext.java:39) at org.exoplatform.services.portletcontainer.plugins.pc.aop.PortletFilterCommand.processAction(PortletFilterCommand.java:108) at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:57) at org.exoplatform.container.component.ExecutionContext.executeNextUnit(ExecutionContext.java:39) at org.exoplatform.services.portletcontainer.plugins.pc.aop.PortletSecurityCommand.processAction(PortletSecurityCommand.java:68) at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:57) at org.exoplatform.container.component.ExecutionContext.executeNextUnit(ExecutionContext.java:39) at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.processAction(BaseCommandUnit.java:93) at org.exoplatform.services.portletcontainer.plugins.pc.aop.BaseCommandUnit.execute(BaseCommandUnit.java:57) at org.exoplatform.container.component.ExecutionContext.execute(ExecutionContext.java:32) at org.exoplatform.services.portletcontainer.plugins.pc.aop.PortletCommandChain.doProcessAction(PortletCommandChain.java:75) at org.exoplatform.services.portletcontainer.plugins.pc.PortletApplicationHandler.process(PortletApplicationHandler.java:284) at org.exoplatform.services.portletcontainer.impl.servlet.ServletWrapper.service(ServletWrapper.java:139) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:535) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:472) at org.exoplatform.services.portletcontainer.plugins.pc.PortletContainerDispatcher.dispatch(PortletContainerDispatcher.java:895) at org.exoplatform.services.portletcontainer.plugins.pc.PortletContainerDispatcher.process(PortletContainerDispatcher.java:818) at org.exoplatform.services.portletcontainer.plugins.pc.PortletContainerDispatcher.processAction(PortletContainerDispatcher.java:670) at org.exoplatform.services.portletcontainer.impl.PortletContainerServiceImpl.processAction(PortletContainerServiceImpl.java:509) at vyre.publishing.portal.PortalFramework.processAction(PortalFramework.java:684) at vyre.publishing.portal.PortalFramework.preRenderProcessing(PortalFramework.java:893) at vyre.publishing.deployment.PageGenerator.prepareForRender(PageGenerator.java:328) at vyre.publishing.deployment.PageGenerator.prepareForRender(PageGenerator.java:211) at vyre.publishing.deployment.PageGenerator.prepareForRender(PageGenerator.java:200) at vyre.publishing.PathFilter.doFilter(PathFilter.java:193) ... 25 more Caused by: org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. null at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:367) at org.apache.commons.fileupload.portlet.PortletFileUpload.parseRequest(PortletFileUpload.java:119) at vyre.util.params.PortletForm.getMap(PortletForm.java:69) ... 74 more Caused by: java.io.IOException at org.apache.jk.common.JkInputStream.receive(JkInputStream.java:199) at org.apache.jk.common.JkInputStream.refillReadBuffer(JkInputStream.java:258) at org.apache.jk.common.JkInputStream.doRead(JkInputStream.java:177) at org.apache.coyote.Request.doRead(Request.java:428) at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:304) at org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:405) at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:327) at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:193) at org.apache.commons.fileupload.MultipartStream$ItemInputStream.makeAvailable(MultipartStream.java:977) at org.apache.commons.fileupload.MultipartStream$ItemInputStream.read(MultipartStream.java:887) at java.io.InputStream.read(InputStream.java:85) at org.apache.commons.fileupload.util.Streams.copy(Streams.java:94) at org.apache.commons.fileupload.util.Streams.copy(Streams.java:64) at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:362) ... 76 more This happens regularly with very large files. MultipartStream appears to be causing problems here. The code that throws the Exception is as follows: lines 963 through 1006 in release 1.2.1 MultipartStream.java private int makeAvailable() throws IOException { if (pos != -1) { return 0; } // Move the data to the beginning of the buffer. total += tail - head - pad; System .arraycopy(buffer, tail - pad, buffer, 0, pad); // Refill buffer with new data. head = 0; tail = pad; for ( ; ; ) { int bytesRead = input.read(buffer, tail, bufSize - tail); if (bytesRead == -1) { // The last pad amount is left in the buffer. // Boundary can't be in there so signal an error // condition. final String msg = "Stream ended unexpectedly" ; throw new MalformedStreamException(msg); } if (notifier != null ) { notifier.noteBytesRead(bytesRead); } tail += bytesRead; findSeparator(); int av = available(); if (av > 0 || pos != -1) { return av; } } } When input.read() is called it returns -1 indicating that there is no more data to be read. For some reason this is considered to be an error, and an Exception is thrown. I've had a look at previous versions of FileUpload, and more or less the same thing has been done for a while. I was wondering if anyone could explain to me why an Exception is thrown in this instance? References http://commons.apache.org/fileupload/apidocs/org/apache/commons/fileupload/MultipartStream.html http://java.sun.com/javase/6/docs/api/java/io/InputStream.html
        Hide
        Luke Scott added a comment - - edited

        It's been quite a long time since I posted this issue... So I don't remember the specifics. It is indeed a problem with Flash and how it uploads files. I ended up using a servlet with the streaming API. Below is a block of code from my class. Much of it is stripped down to include the important stuff. It won't work as-is, but hopefully will be of some help:

        public class UploadServlet extends HttpServlet {
        
        	public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        
        		String[] session = request.getParameterValues("s");
        		Boolean isMultipart = ServletFileUpload.isMultipartContent(request);
        		
        		if( request.getContentLength() > 0 && isMultipart && session != null && session.length > 0 )
        		{
        			try
        			{
        				ServletFileUpload upload = new ServletFileUpload();
        				FileItemIterator iter = upload.getItemIterator(request);
        				
        				while( iter.hasNext() )
        				{
        	   				FileItemStream item = iter.next();
        	   				InputStream stream = item.openStream();
        
        	   				if( !item.isFormField() && item.getFieldName().equals("Filedata") )
        					{
        						String filename = Long.toString(System.currentTimeMillis(), 36);
        						String tmpPath = "." + filename + ".tmp";
        						String finPath = filename;
        						OutputStream outstream = new FileOutputStream( tmpPath );
        						Streams.copy(stream,outstream,true);
        						
        						stream.close();
        						outstream.close();
        
        						File tmpFile = new File( tmpPath );
        						File finFile = new File( finPath );
        							
        						tmpFile.renameTo( finFile );
           					}
        				}
        			}
        			catch( Exception e ) { }
        		}
        
        	} 
        }
        
        Show
        Luke Scott added a comment - - edited It's been quite a long time since I posted this issue... So I don't remember the specifics. It is indeed a problem with Flash and how it uploads files. I ended up using a servlet with the streaming API. Below is a block of code from my class. Much of it is stripped down to include the important stuff. It won't work as-is, but hopefully will be of some help: public class UploadServlet extends HttpServlet { public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String [] session = request.getParameterValues( "s" ); Boolean isMultipart = ServletFileUpload.isMultipartContent(request); if ( request.getContentLength() > 0 && isMultipart && session != null && session.length > 0 ) { try { ServletFileUpload upload = new ServletFileUpload(); FileItemIterator iter = upload.getItemIterator(request); while ( iter.hasNext() ) { FileItemStream item = iter.next(); InputStream stream = item.openStream(); if ( !item.isFormField() && item.getFieldName().equals( "Filedata" ) ) { String filename = Long .toString( System .currentTimeMillis(), 36); String tmpPath = "." + filename + ".tmp" ; String finPath = filename; OutputStream outstream = new FileOutputStream( tmpPath ); Streams.copy(stream,outstream, true ); stream.close(); outstream.close(); File tmpFile = new File( tmpPath ); File finFile = new File( finPath ); tmpFile.renameTo( finFile ); } } } catch ( Exception e ) { } } } }
        Hide
        raghunath added a comment -

        Hi

        I'm also having same issue. Uploading is failing at 40%. Even after trying many trials , still struck in the problem.

        Any workarounds please.

        -raghu

        Show
        raghunath added a comment - Hi I'm also having same issue. Uploading is failing at 40%. Even after trying many trials , still struck in the problem. Any workarounds please. -raghu
        Hide
        Simone Tripodi added a comment -

        Workaround (re)included in r1455085, FAQ will be republished as soon as the site will be redeployed

        Show
        Simone Tripodi added a comment - Workaround (re)included in r1455085, FAQ will be republished as soon as the site will be redeployed

          People

          • Assignee:
            Jochen Wiedmann
            Reporter:
            Luke Scott
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development