forked from mtusi2026/mtusi2026lab5
20 lines
665 B
Python
20 lines
665 B
Python
"""Private S3 access; no automatic PUT retries, explicit bounded timeouts."""
|
|
import os
|
|
from pathlib import Path
|
|
import boto3
|
|
from botocore.config import Config
|
|
|
|
|
|
def secret(name):
|
|
return Path(os.environ[name + '_FILE']).read_text().strip()
|
|
|
|
|
|
BUCKET = os.getenv('S3_BUCKET', 'messenger-attachments')
|
|
s3 = boto3.client(
|
|
's3', endpoint_url=os.getenv('S3_ENDPOINT', 'http://s3:9000'),
|
|
region_name='us-east-1', aws_access_key_id=secret('S3_ACCESS_KEY_ID'),
|
|
aws_secret_access_key=secret('S3_SECRET_ACCESS_KEY'),
|
|
config=Config(connect_timeout=2, read_timeout=5, retries={'total_max_attempts': 1},
|
|
s3={'addressing_style': 'path'}),
|
|
)
|