4

I have been working on an android project in which I have to download/upload few files via HTTP. I was wondering if there is a way to have resumable downloads/uploads for the files. As in, if my file is being downloaded or uploaded and there is a subtle internet choke for very minimal time (this sometimes corrupts the file and the process is stopped and next time it starts from 0 ) the downloading/uploading is paused and once the internet is back again on my device, the downloading/uploading starts from the same point where it was stopped at so that the file does not get corrupted and the process does not start from 0.

Is there any way to achieve this functionality in android/Java ? Please do let me know. Thanks in advance.

4

1 回答 1

2

Html 本身不提供这种分块加载文件的能力。FileUpload是一个简单的对象,它与整个文件一起工作,因此从头开始发送它。为了满足您的要求,您需要更复杂的客户端/服务器关系。Java Applet 是在客户端这样做的好选择,而服务器端是微不足道的。但是,您需要实现一些协议(如握手、开始发送文件、从某个位置继续、验证),这不是一件容易的事。即使是最常见的协议(例如 ftp)也不提供这种能力。即使你创造了所有这些东西,它也只会与自己兼容。真的值得所有的努力吗?常见的答案是——不。这就是为什么我们在野外看不到这种方法的原因。

于 2015-05-10T02:19:09.327 回答