split files, database and S3, models

This commit is contained in:
2026-04-16 20:24:06 +08:00
parent 66f9f8fb72
commit b0d151333c
4 changed files with 96 additions and 75 deletions
+26
View File
@@ -0,0 +1,26 @@
import boto3
from .config import settings
s3_client = boto3.client(
's3',
aws_access_key_id=settings.s3_access_key,
aws_secret_access_key=settings.s3_secret_key,
endpoint_url=settings.s3_endpoint,
region_name=settings.s3_region
)
def upload_to_s3(key: str, content: str):
s3_client.put_object(
Bucket=settings.s3_bucket_name,
Key=key,
Body=content,
ContentType="text/markdown"
)
def delete_from_s3(keys: list[str]):
if not keys:
return
s3_client.delete_objects(
Bucket=settings.s3_bucket_name,
Delete={'Objects': [{'Key': k} for k in keys]}
)