That should work fine if you use the AtomPub binding. It pulls the bytes 
directly from the underlying repository. The Web Services binding buffers the 
stream. If the content is <=4MB it is buffered in main memory. If it is >4MB it 
is buffered in a temporary file. (This threshold can be changed by a session 
parameter.) The temporary file adds significant overhead for large contents, 
but it still should work.

I have tested it with content up to 1GB. If you have something bigger than that 
please let us know if it works or doesn't work.


Cheers,

Florian


----- Original Message -----
From: "Naresh Bhatia" <[email protected]>
To: "dev" <[email protected]>
Sent: Saturday, June 4, 2011 12:54:35 AM GMT +00:00 GMT Britain, Ireland, 
Portugal
Subject: Returning content stream in HttpServletResponse

I would like to return the content of a document in a HttpServletResponse.
What I have right now is shown below. Is there a better way? Will this scale
for large video content?

InputStream src = new BufferedInputStream(
        document.getContentStream().getStream());

BufferedOutputStream dst = new BufferedOutputStream(
        response.getOutputStream());

byte[] buff = new byte[2048];
int bytesRead;
while((bytesRead = src.read(buff, 0, buff.length)) != -1) {
    dst.write(buff, 0, bytesRead);
}


Thanks.
Naresh

Reply via email to