feat:初始化工程

This commit is contained in:
2026-07-27 20:00:57 +08:00
commit 3ebb249516
16 changed files with 414 additions and 0 deletions

24
storage.py Normal file
View File

@@ -0,0 +1,24 @@
import os
import boto3
from botocore.config import Config
from dotenv import load_dotenv
load_dotenv()
ENDPOINT = os.getenv("RUSTFS_ENDPOINT")
BUCKET = os.getenv("RUSTFS_BUCKET")
_s3 = boto3.client(
"s3",
endpoint_url=ENDPOINT,
aws_access_key_id=os.getenv("RUSTFS_ACCESS_KEY"),
aws_secret_access_key=os.getenv("RUSTFS_SECRET_KEY"),
config=Config(signature_version="s3v4"),
region_name="us-east-1",
)
def upload_rustfs(file_obj, filename: str) -> str:
_s3.upload_fileobj(file_obj, BUCKET, filename)
return f"{ENDPOINT}/{BUCKET}/{filename}"