Java服务器端发送文件并支持恢复?

发布于 2024-10-18 00:22:05 字数 112 浏览 6 评论 0原文

我试图让我的java服务器传输一个Web浏览器可以下载的文件。

但是,我希望浏览器能够暂停并恢复文件传输,而不是重新开始下载。

有人知道服务器端的java代码可以解决这个问题吗?

I am trying to allow my java server to transfer a file where a web browser can download.

However, I want the browser if they pause and resume the file transfer to work and not start the download all over again.

Anyone know java code for the server side to fix this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我不咬妳我踢妳 2024-10-25 00:22:05

支持可断点下载分为两部分:

如果您提供静态资源,最好的选择是使用代理服务器(例如 Apache)来处理下载。如果代理服务器不是一个选项,那么您可能可以找到与您的应用程序服务器捆绑在一起的 Servlet;例如,Tomcat 有 DefaultServlet。此选项的缺点是它会在应用程序和应用程序服务器之间创建硬依赖关系,这可能是不可接受的。

如果您决定自己开发,我建议您查看 Apache 的 HTTP 组件。这是一个很好的 API,使处理 HTTP 请求和响应变得更加容易。

There are two parts to supporting resumable downloads:

If you're serving up a static resource your best bet is to use a proxy server, like Apache, to handle the download. If a proxy server isn't an option then you can probably find a Servlet that is bundled with your app server; for example, Tomcat has as DefaultServlet. The downside to this option is that it creates a hard dependency between your application and the application server, which may not be acceptable.

If you decide to roll your own I recommend taking a look at Apache's HTTP Components. It's a nice API that makes working with HTTP requests and responses much easier.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文