教师教材编辑页面
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user