'Python Requests API GET download facing network flapping
I am trying to use python requests for GET method to download files by API call. the problem is that when any network flap occurs the script assumes the file is fully downloaded and I end up with a corrupted file. I am using the below sample code
response = requests.get(url, headers=auth_headers, verify=False, timeout=100)
print ("Content/Backup lenght/size = "+ str(len(response.content)))
open(filename, 'wb').write(response.content)
I tried to use the timeout but it didn't add any value. also, the size of the file is not fixed to validate it and it keeps getting bigger so the probability of a network flap during the download increases over time.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
