hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Sean Taylor <da...@bluesunrise.com>
Subject InputStream part source
Date Thu, 17 Jul 2003 20:22:54 GMT
I created a little class called InputStreamPartSource to wrapper an  
input stream as a part source.

MultipartPostMethod post  = new  
InputStreamPartSource source = new InputStreamPartSource(stream,  
FilePart part = new FilePart("business.xml", source);
int status = client.executeMethod(post);

It seems that the abstract class Part is calling createInputStream  
twice on my source.
Why does it need to create the stream twice?
This causes a bad file descriptor since the stream was already closed  
after the first call.
The stream is an expensive resource which comes from a CMS system and I  
prefer not to create it twice.
Is this a bug are normal/required behavior?

InputStreamPartSource Class included below

public class InputStreamPartSource implements PartSource
	InputStream stream = null;
	String filename = null;
	int length = 0;
	public InputStreamPartSource(InputStream stream, String filename, int  
		this.stream = stream;
		this.filename = filename;
		this.length = length;
     /* (non-Javadoc)
      * @see  
     public InputStream createInputStream()
     throws IOException
     	return this.stream;

     /* (non-Javadoc)
      * @see  
     public String getFileName()
         return this.filename;

     /* (non-Javadoc)
      * @see  
     public long getLength()
         return this.length;

David Sean Taylor
Bluesunrise Software
+01 707 773-4646

View raw message