I have a large .mp4 file that I am trying to download from an API and write the contents to it. It runs a long time and then I get the ChunkedEncodingError: ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read)). How can I make this work successfully and write the file successfully.
Here is my code:
if '.mp4' in assetFileName:
myfile = requests.get(stepAssetURL, stream=True, auth=HTTPBasicAuth(UserID, UserPassword))
destPath = path + assetFileName
with open(destPath, 'wb') as d:
for chunk in myfile.iter_content(chunk_size=1024):
print(chunk)
if chunk:
d.write(chunk)