I have already tried code from StackOverflow, f.e. Download, pause and resume an download using Indy components.
But when I try to use IdHttp1.Disconnect() in order to pause download and then resume it, the download does not resume. The file is downloaded from zero. So, what should I do in order to add resume support to my Delphi app?
BTW: the server allows download resuming, because IDM can resume the download.
You have to check the size of the remote file, and the size of the local file (if exists). If the size of the remote file is larger than the size of the local file, then you have to set the
Rangesproperty of theRequestproperty ofTIdHTTPto the starting point (the local file size).For example, if the remote file size is 100000 bytes, and the local file size is 80000 bytes, then you have to set
http.Request.Rangesto start at 80000.Here is a fully working code for you to use: