使用Java Jersey返回一个文件 [英] Return a file using Java Jersey

查看:113
本文介绍了使用Java Jersey返回一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Java Jersey来实现REST服务。
我的服务应提供的一件事是文件下载选项。
这些文件非常大,是根据db的数据构建的。

I am using the Java Jersey to implement a REST service. One thing my service should provide is a file download option. These files are quite big and are constructed from data from db.

目前我从数据库获取所有数据并将其保存到文件
并返回

Currently I am fetching all data from the db and saving it to a file and returning a

Response.ok().entity(new FileInputStream(file)).build();

有没有办法在不完全从db下载数据的情况下开始提供文件,但是数据是否来自db将其附加到输出流?

Is there a way how I can start serving the file without fully downloading the data from db, but as the data comes from db append it to the Output stream ?

推荐答案

使用使用JERSEY输入和输出二进制流?

这篇关于使用Java Jersey返回一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆