One last advise: Make sure that you close the content stream when you don't need it anymore! That cleans up the underlying resources and the connection to the repository can be reused, which improves the overall performance. If you have to handle a lot parallel connections to the repository, you might also want to experiment with the system property http.maxConnections.
Florian ----- Original Message ----- From: "Naresh Bhatia" <[email protected]> To: [email protected] Sent: Saturday, June 4, 2011 3:25:08 PM GMT +00:00 GMT Britain, Ireland, Portugal Subject: Re: Returning content stream in HttpServletResponse Thanks Sebastian and Florian, I am assuming from your responses that the streams provided by OpenCimis ( doc.getContentStream().getStream() ) and the Servlet (ServletOutputStream) are appropriate to use as is, i.e. they provide some sort of buffering. So I am taking out BufferedInputStream and BufferedOutputStream from my code. If this assumption is incorrect, please let me know. Thanks Naresh On Sat, Jun 4, 2011 at 7:10 AM, Florian Müller <[email protected] > wrote: > 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 >
