ЛР 5: очередь и асинхронная обработка изображений

This commit is contained in:
2026-11-11 19:59:42 +03:00
parent 276dbdad8a
commit af485c93d4
54 changed files with 1966 additions and 34 deletions
+19
View File
@@ -0,0 +1,19 @@
"""S3 access with least-privilege application credentials (never root credentials)."""
import os
from pathlib import Path
import boto3
from botocore.config import Config
def s3_client():
return boto3.client(
's3', endpoint_url=os.environ['S3_ENDPOINT'],
region_name=os.getenv('S3_REGION','us-east-1'),
aws_access_key_id=Path(os.environ['S3_ACCESS_KEY_ID_FILE']).read_text().strip(),
aws_secret_access_key=Path(os.environ['S3_SECRET_ACCESS_KEY_FILE']).read_text().strip(),
config=Config(connect_timeout=2,read_timeout=15,retries={'max_attempts':2},
s3={'addressing_style':'path'}))
def bucket():
return os.getenv('S3_BUCKET','messenger-attachments')