Commit c607b9ea authored by ZZH's avatar ZZH

news upload to public Qs bucket 2024-03-8

parent 4c88642c
......@@ -5,12 +5,13 @@ DATE:2024/3/6 13:47
"""
from pot_libs.logger import log
from pot_libs.qingstor_util.qs_client import QsClient
from pot_libs.settings import SETTING
async def upload_file(file, qs_url):
async def upload_file(file, qs_url, bucket=SETTING.qingstor_bucket):
file_body = file.body
if file_body:
async with QsClient() as client:
async with QsClient(bucket) as client:
resp = await client.put_file(key=qs_url, data=file_body)
log.info(f"upload to qingstor the resp: {resp} {qs_url}")
return 1
......
......@@ -24,7 +24,7 @@ async def upload_file_helper(file):
file_url = f"{OSS_NEWS}/{yr}/{month}/{uuid4()}.{file_name_lst[1]}"
log.info(f"准备上传文件 {file_name} {file_url}")
is_upload = await upload_file(file, file_url)
is_upload = await upload_file(file, file_url, bucket="qk-public-dev")
return is_upload, file_url
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment