1

我有一个大的 .mp4 文件,我试图从 API 下载并将内容写入其中。它运行了很长时间,然后我得到 ChunkedEncodingError: ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))。我怎样才能成功地完成这项工作并成功地写入文件。

这是我的代码:

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)
4

0 回答 0