教师教材编辑页面

This commit is contained in:
CakeCN
2025-08-31 00:30:53 +08:00
parent 06e2e69b44
commit b18c981367
10 changed files with 573 additions and 38 deletions

View File

@@ -1,10 +1,23 @@
from flask import current_app
def upload_file(rb_file, file_name):
if file_name is not None and "/" in file_name:
file_name = file_name.split("/")[-1]
cos_client = current_app.extensions["cos_client"]
cos_client.put_object(
Bucket=current_app.config["TENCENT_COS"]["bucket"],
Body=rb_file,
Key=file_name,
)
return f"https://{current_app.config['TENCENT_COS']['bucket']}.cos.{current_app.config['TENCENT_COS']['region']}.myqcloud.com/{file_name}"
return f"https://{current_app.config['TENCENT_COS']['bucket']}.cos.{current_app.config['TENCENT_COS']['region']}.myqcloud.com/{file_name}"
def delete_file(file_name):
if file_name is not None and "/" in file_name:
file_name = file_name.split("/")[-1]
cos_client = current_app.extensions["cos_client"]
cos_client.delete_object(
Bucket=current_app.config["TENCENT_COS"]["bucket"],
Key=file_name,
)
return True