[Opensource] Re: file uploads bug

will laidback at telus.net
Mon Jan 13 22:26:08 PST 2003


Oops, typo, solution one should be:
  OutputStream ops = item.getOutputStream();
  multi.readBodyData(ops);
  ops.close();

will wrote:

> FYI,
>
> I am working on an application build on Expresso 5.0.2. While attempting
> to get the application to upload file using the built in Expresso
> functionality I encountered a problem. Files were getting to the default
> temp directory but once there, I could not delete them within the same
> request.
>
> I think the following two items are bugs that you should be aware of:
>
> 1.
> Method: com.jcorporate.expresso.core.misc.upload.Uploader.parseRequest(
> HttpServletRequest, ParameterParser, path)
>
> Description: In three places your code does this:
>
> multi.readBodyData(item.getOutputStream());
> The getOutputStream() method returns an OutputStream but I could not
> find any code that closed this OutputStream.
>
> Solution: I changed my local file to this:
>                                 OutputStream ops =
> item.getOutputStream();
>
> multi.readBodyData(item.getOutputStream());
>
> ops.close();
>
> 2.
> Method: com.jcorporate.expresso.core.misc.FileUtil.copyFile(String,
> String)
>
> Description: At the bottom of this method a buffer is flushed and two
> OutputStreams are closed:
>                                 bout.flush();
>                                 bin.close();
>                                 fin.close();
> Unfortunately there are four OutputStreams in this method.
>
> Solution: I changed my local file to this:
>                                 bout.flush();
>                                 bout.close();
>                                 fout.close();
>                                 bin.close();
>                                 fin.close();
>
> This solved the problem and allowed the uploaded file to be moved to a
> permanent directory in the same request. Please let me know if there is
> a better solution.
>
> Cheers,
> Will




More information about the Opensource mailing list