How to resume file download in Python?
If the web server supports the range request then you can add the Range header to your request:
Range: bytes=StartPos-StopPos
You will receive the part between StartPos and StopPos. If dont know the StopPos just use:
Range: bytes=StartPos-
So your code would be:
def resume_download(fileurl, resume_byte_pos):
resume_header = {'Range': 'bytes=%d-' % resume_byte_pos}
return requests.get(fileurl, headers=resume_header, stream=True, verify=False, allow_redirects=True)