This commit is contained in:
yumoqing 2025-09-23 13:38:39 +08:00
parent 3a4ef54399
commit 6d700279fe

View File

@ -187,13 +187,13 @@ async def downloadfile(url, headers=None, params=None, data={}):
fs = FileStorage() fs = FileStorage()
fpath = fs._name2path(filename, userid='tmp') fpath = fs._name2path(filename, userid='tmp')
try: try:
shc = StreamHttpClient()
async with aiofiles.open(fpath,'wb') as f: async with aiofiles.open(fpath,'wb') as f:
shc = StreamHttpClient()
async for chunk in shc('GET', url, async for chunk in shc('GET', url,
headers=headers, headers=headers,
params=params, params=params,
data=data): data=data):
f.write(chunk) await f.write(chunk)
return fpath return fpath
except Exception as e: except Exception as e:
exception(f'save {url} to {fpath} exception:{e}') exception(f'save {url} to {fpath} exception:{e}')