简体   繁体   English

如何使用多部分下载来远程下载文件?

[英]how to remote download a file using multi-part downloading?

i want to download a remote file on internet to my host. 我想将Internet上的远程文件下载到主机。 but i want to download it with multi-part downloading to make it download faster. 但我想通过多部分下载来下载它,以使其下载速度更快。 just the same as download managers . 下载管理器一样

You have to use Range header while requesting. 您必须在请求时使用Range标头。

Sending Range: bytes=500-999 will download the bytes form 500 to 999; 发送Range: bytes=500-999将从500到999下载字节;

Note: PHP is not a multi-threaded language. 注意:PHP 不是多线程语言。 So even you download by multi-part it'll be sequential. 因此,即使您分批下载,它也将是连续的。 Unless you fork multiple process. 除非您分叉多个过程。 Though using third-party extensions like curl you can do this through curl_multi_exec 尽管使用诸如curl之类的第三方扩展,您可以通过curl_multi_exec做到这curl_multi_exec

This will be dependent on the server that you are downloading from supporting Range Requests. 这将取决于您要从支持范围请求下载的服务器。 Read up on Range Requests , and combine this with a multi-threaded cURL , and you'll be able to have more than one download stream working at a time. 阅读范围请求 ,并将其与多线程cURL结合使用,您将一次可以运行多个下载流。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM