You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-user@jakarta.apache.org by Nick Longinow <ni...@vanhooseassociates.com> on 2004/10/08 23:07:00 UTC

Piping a repository file into an Outputstream...

Hi,

 

I am putMethod(path, inputstream) binary documents (Word, PDF, etc) into the
Slide repository (2.1b1) and then retrieving them into an OutputStream for
download via the getMethod.  Using:

 
InputStream is = resource.getMethodData().
byte [] info = new byte[ resource.getContentLength() ];
is.read( info );
out.write( info );

 

This will write "invalid" data into the stream such that the parent
applcation (ie, Word) will not recognize it, and barfs.

However, if I replace these calls with writing to a temporary File, it
works, all the time every time.
byte [] info = new byte[ resource.getContentLength() ];
File file = new File("temp");
boolean ok = resource.getMethod(file);
FileInputStream fis = new FileInputStream(file);
fis.read(info);
out.write( info );

 

Any ideas why this occurs ?