How do I download only a little part of a big file? [closed]

左心房为你撑大大i 提交于 2019-12-26 14:36:48

问题


How do I download only a little part of a big file in Delphi? (like Download Manager)

For example, suppose I want to get the first 300 bytes of a 100MB text file over HTTP.


回答1:


getting the first 300 bytes of a 100MB file.

Using WinInet library you can specify in the parameters how many bytes from the beginning of file do you actually need.

http://msdn.microsoft.com/en-us/library/windows/desktop/aa385103.aspx


In case you would later want some chunk from in-between you may investigate 3rd-party libraries. With those libraries you need to set HTTP request Range header - https://en.wikipedia.org/wiki/List_of_HTTP_header_fields

  • There is no online help for http://www.overbyte.be/eng/products/ics.html but maybe in sources you would find support for it.

  • There are numeric properties in http://synapse.ararat.cz/doc/help/httpsend.THTTPSend.html#RangeStart

  • There is string property in http://www.indyproject.org/docsite/html/TIdRequestHeaderInfo_Range.html for TIdHTTP.Request object.

However the server may ignore this header. The library that you choose should check if server retirned Content-Range in HTTP Response and do something if it did not. Maybe download from very file start or maybe throw an exception. You should test those libraries and understand their behaviour in such a case.



来源:https://stackoverflow.com/questions/17597235/how-do-i-download-only-a-little-part-of-a-big-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!