feat: add s3 client and image validation utils

This commit is contained in:
2026-11-11 20:19:41 +03:00
parent 1aa91ddfec
commit 8ab7245f9c
2 changed files with 45 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
import boto3
from botocore.client import Config
import os
s3 = boto3.client(
"s3",
endpoint_url=os.getenv("S3_ENDPOINT", "http://minio:9000"),
aws_access_key_id=os.getenv("S3_ACCESS_KEY", "minioadmin"),
aws_secret_access_key=os.getenv("S3_SECRET_KEY", "minioadmin"),
config=Config(signature_version="s3v4"),
region_name="us-east-1",
)
BUCKET = os.getenv("S3_BUCKET", "attachments")
def ensure_bucket():
try:
s3.head_bucket(Bucket=BUCKET)
except Exception:
s3.create_bucket(Bucket=BUCKET)