后端下载进度条打印
This commit is contained in:
parent
4a4252e0cd
commit
8c10762705
@ -1 +1 @@
|
|||||||
3.9.48beta26
|
3.9.48beta27
|
||||||
@ -51,7 +51,8 @@ def get_file_name(url, headers):
|
|||||||
def file_download(fileUrl, filePath):
|
def file_download(fileUrl, filePath):
|
||||||
if os.path.exists(filePath):
|
if os.path.exists(filePath):
|
||||||
os.remove(filePath)
|
os.remove(filePath)
|
||||||
response = requests.get(fileUrl, headers=headers, stream=True, verify=False)
|
# response = requests.get(fileUrl, headers=headers, stream=True, verify=False)
|
||||||
|
response = requests.get(fileUrl, headers=headers, stream=True)
|
||||||
fileSize = int(response.headers['content-length']) # 文件大小
|
fileSize = int(response.headers['content-length']) # 文件大小
|
||||||
logger.info(f'fileSize:{fileSize}')
|
logger.info(f'fileSize:{fileSize}')
|
||||||
|
|
||||||
@ -76,7 +77,7 @@ def file_download(fileUrl, filePath):
|
|||||||
|
|
||||||
if remainSize > 0:
|
if remainSize > 0:
|
||||||
|
|
||||||
with closing(requests.get(fileUrl, headers=_headers, stream=True, verify=False)) as _response, open(
|
with closing(requests.get(fileUrl, headers=_headers, stream=True)) as _response, open(
|
||||||
filePath,
|
filePath,
|
||||||
"ab") as file:
|
"ab") as file:
|
||||||
for content in _response.iter_content(chunk_size=chunkSize):
|
for content in _response.iter_content(chunk_size=chunkSize):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user