solr:向 SolrQueryResponse 添加内容处置
我有一个扩展 RequestHandlerBase 的自定义请求处理程序。
此处理程序的目的是搜索给定用户查询的索引。不应忽略客户端浏览器上的结果,而应将响应数据下载为文件。这是我的handleRequestBody函数代码
@Override
public void handleRequestBody(final, SolrQueryRequest req,final SolrQueryResponse res) {
tempFile = File.createTempFile(UUID.randomUUID().toString(),".tmp", new File(FILE_PATH));
writeSearchResultstoFile(tempFile);
ContentStreamBase outConentStream = new ContentStreamBase.FileStream(tempFile);
outConentStream.setContentType("application/download");
rsp.add(RawResponseWriter.CONTENT, outConentStream);
}
问题是文件正在客户端与.part文件一起下载。 rsp.getResponseHeader().add("Content-Disposition", "filename=data.csv");
没有多大帮助。有人可以告诉我如何设置内容处置吗?
I have a custom request handler that is extending RequestHandlerBase.
The purpose of this handler is to search the index for the given user query. Instead of omitting the results on the browser at client side, the response data should be downloaded as a file. Here is my handleRequestBody function code
@Override
public void handleRequestBody(final, SolrQueryRequest req,final SolrQueryResponse res) {
tempFile = File.createTempFile(UUID.randomUUID().toString(),".tmp", new File(FILE_PATH));
writeSearchResultstoFile(tempFile);
ContentStreamBase outConentStream = new ContentStreamBase.FileStream(tempFile);
outConentStream.setContentType("application/download");
rsp.add(RawResponseWriter.CONTENT, outConentStream);
}
The problem is the file is being downloaded with .part file at client side.
rsp.getResponseHeader().add("Content-Disposition", "filename=data.csv");
didn't help much. Could some please tell me how to set the Content-Disposition.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于我看到您将结果格式化为 CSV,我很好奇您是否查看过 CSVResponseFormat Solr 从 3.1 版本开始就支持
Since I see that you are formatting your results as CSV I am curious as to whether you have looked at the CSVResponseFormat that Solr has supported since release 3.1