Rename MinIO config to S3, switch to Cloudflare R2
- Rename MinioConfig → S3Config, settings.minio → settings.s3 - Update config.example.yaml with R2 endpoint template - S3 service is now storage-backend agnostic (MinIO, R2, any S3-compatible) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -11,9 +11,9 @@ from app.config import settings
|
||||
def _get_client():
|
||||
return boto3.client(
|
||||
"s3",
|
||||
endpoint_url=settings.minio.endpoint,
|
||||
aws_access_key_id=settings.minio.access_key,
|
||||
aws_secret_access_key=settings.minio.secret_key,
|
||||
endpoint_url=settings.s3.endpoint,
|
||||
aws_access_key_id=settings.s3.access_key,
|
||||
aws_secret_access_key=settings.s3.secret_key,
|
||||
config=BotoConfig(signature_version="s3v4"),
|
||||
)
|
||||
|
||||
@@ -33,7 +33,7 @@ def upload_image(file_bytes: bytes, original_filename: str) -> str:
|
||||
content_type = "image/png"
|
||||
|
||||
client.put_object(
|
||||
Bucket=settings.minio.bucket,
|
||||
Bucket=settings.s3.bucket,
|
||||
Key=object_key,
|
||||
Body=file_bytes,
|
||||
ContentType=content_type,
|
||||
@@ -43,12 +43,12 @@ def upload_image(file_bytes: bytes, original_filename: str) -> str:
|
||||
|
||||
def _get_presign_client():
|
||||
"""Client using public endpoint so presigned URL signatures match the public host."""
|
||||
endpoint = settings.minio.public_endpoint or settings.minio.endpoint
|
||||
endpoint = settings.s3.public_endpoint or settings.s3.endpoint
|
||||
return boto3.client(
|
||||
"s3",
|
||||
endpoint_url=endpoint,
|
||||
aws_access_key_id=settings.minio.access_key,
|
||||
aws_secret_access_key=settings.minio.secret_key,
|
||||
aws_access_key_id=settings.s3.access_key,
|
||||
aws_secret_access_key=settings.s3.secret_key,
|
||||
config=BotoConfig(signature_version="s3v4"),
|
||||
)
|
||||
|
||||
@@ -58,7 +58,7 @@ def generate_presigned_put_url(object_key: str) -> str:
|
||||
url: str = client.generate_presigned_url(
|
||||
"put_object",
|
||||
Params={
|
||||
"Bucket": settings.minio.bucket,
|
||||
"Bucket": settings.s3.bucket,
|
||||
"Key": object_key,
|
||||
},
|
||||
ExpiresIn=300,
|
||||
|
||||
Reference in New Issue
Block a user