Java server side sending file with resume support?

前端 未结 1 1654
无人共我
无人共我 2020-12-09 14:20

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 wo

相关标签:
1条回答
  • 2020-12-09 14:53

    There are two parts to supporting resumable downloads:

    • Your response needs to return the Accept-Ranges and Content-Range headers
    • You need to write code that can then handle the HTTP Range headers and If-Range to know where a client needs to resume

    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.

    0 讨论(0)
提交回复
热议问题