[英]Retrieve Blob data (pdf) using java in Google app Engine
I have a database in which there is one field with Blob data. 我有一个数据库,其中有一个包含Blob数据的字段。 I want to put the download link on this file.
我想将下载链接放在此文件上。 i have used
我用过
resp.setContentType("application/pdf");
resp.getOutputStream().write(content.getBytes());
to get the pdf file. 获取pdf文件。 I am able to get the file but it gets downloaded on the page in which this code is written.
我可以获取该文件,但可以在编写此代码的页面上将其下载。 I want to put the link with file name and on clicking the link i want to download this file.
我想在链接中添加文件名,然后单击链接以下载此文件。
I would simply add a target="_blank"
attribute in your download link: 我只需在您的下载链接中添加
target="_blank"
属性:
<a target="_blank" href="http://pathtothedownloadservlet">Download this pdf</a>
or, as said by Nick, use the Content Disposition like this: 或者,如Nick所说,使用Content Disposition像这样:
resp.setHeader( "Content-Disposition", "attachment;filename=test.pdf");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.