开发者

Generate and return docx file to client

I have an app that generates a docx file base on user inp开发者_如何学Cut. It uses Apache POI to generate the docx file and I can get the FileOutputStream from that, the document opens perfectly on a local machine when I write it to a file.

The webapp is using Dojo xhrPost to send the necessary data to the server to generate the document. What I am wondering is how I get the docx file to the client.

I know I can do it be creating a temp file and passing the location of that file to the client to download, but I would think there would be a way to do it by piping the FileOutputStream straight to the client, which would be much cleaner.

Any suggestions?


The answer from Mr Shiny in this SO question has an example streaming an excel file, should be very similar for a docx:

How can I get an Input Stream from HSSFWorkbook Object

Except that a docx content type should, probably, be application/vnd.ms-word

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜