On Feb 26, 11:50 am, Jeppe Nejsum Madsen <je...@ingolfs.dk> wrote: > Hi, > > I need to create a response that downloads a file. The file is > generated by a 3rd party api that takes an output stream as the target > for the file. As the file can be rather large, I would like to stream > this file directly to the client. > > I've looked at StreamingResponse, but this seem to require something > akin to an input stream. > > As there a way to generate a response with direct access to the output stream?
No. IMO this would bring serious problems related with "committed response" if people will start writing directly into servlet's response output stream. But you should be able to bridge the outputstream needed by that library and the "inputstream" from the StreamingResponse ( which takes a structural type not really an InputStream) through mechanisms similar with Pipes. You could also build your own OutputStream that also has def read(buf: Array[Byte]): Int. Thus your library will write stuff in your OutputStream, you would then buffer the data and wait for that data to be drained by the servlet's input stream. A simple producer/consumer approach. > > /Jeppe -- You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.