All checks were successful
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-ai-compliance (push) Successful in 36s
CI / test-python-backend-compliance (push) Successful in 31s
CI / test-python-document-crawler (push) Successful in 23s
CI / test-python-dsms-gateway (push) Successful in 21s
Phase A: 8 new IT-Security training modules (SEC-PWD, SEC-DESK, SEC-KIAI, SEC-BYOD, SEC-VIDEO, SEC-USB, SEC-INC, SEC-HOME) with CTM entries. Bulk content and quiz generation endpoints for all 28 modules. Phase B: Piper TTS service (Python/FastAPI) for local German speech synthesis. training_media table, TTSClient in Go backend, audio generation endpoints, AudioPlayer component in frontend. MinIO storage integration. Phase C: FFmpeg presentation video pipeline — LLM generates slide scripts, ImageMagick renders 1920x1080 slides, FFmpeg combines with audio to MP4. VideoPlayer and ScriptPreview components in frontend. New files: 15 created, 9 modified - compliance-tts-service/ (Dockerfile, main.py, tts_engine.py, storage.py, slide_renderer.py, video_generator.py) - migrations 014-016 (training engine, IT-security modules, media table) - training package (models, store, content_generator, media, handlers) - frontend (AudioPlayer, VideoPlayer, ScriptPreview, api, types, page) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
57 lines
1.9 KiB
Python
57 lines
1.9 KiB
Python
"""MinIO/S3 storage client for audio and video files."""
|
|
import logging
|
|
import boto3
|
|
from botocore.exceptions import ClientError
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class StorageClient:
|
|
"""S3-compatible storage client for MinIO."""
|
|
|
|
def __init__(self, endpoint: str, access_key: str, secret_key: str, secure: bool = False):
|
|
self.client = boto3.client(
|
|
"s3",
|
|
endpoint_url=f"{'https' if secure else 'http'}://{endpoint}",
|
|
aws_access_key_id=access_key,
|
|
aws_secret_access_key=secret_key,
|
|
region_name="us-east-1",
|
|
)
|
|
self.endpoint = endpoint
|
|
|
|
def ensure_bucket(self, bucket: str) -> None:
|
|
"""Create bucket if it doesn't exist."""
|
|
try:
|
|
self.client.head_bucket(Bucket=bucket)
|
|
except ClientError:
|
|
try:
|
|
self.client.create_bucket(Bucket=bucket)
|
|
logger.info(f"Created bucket: {bucket}")
|
|
except ClientError as e:
|
|
logger.error(f"Failed to create bucket {bucket}: {e}")
|
|
|
|
def upload_file(self, bucket: str, object_key: str, file_path: str, content_type: str = "audio/mpeg") -> int:
|
|
"""Upload a file to storage and return file size in bytes."""
|
|
import os
|
|
self.client.upload_file(
|
|
file_path, bucket, object_key,
|
|
ExtraArgs={"ContentType": content_type},
|
|
)
|
|
return os.path.getsize(file_path)
|
|
|
|
def get_presigned_url(self, bucket: str, object_key: str, expires: int = 3600) -> str:
|
|
"""Generate a presigned URL for file access."""
|
|
return self.client.generate_presigned_url(
|
|
"get_object",
|
|
Params={"Bucket": bucket, "Key": object_key},
|
|
ExpiresIn=expires,
|
|
)
|
|
|
|
def is_connected(self) -> bool:
|
|
"""Check if storage is accessible."""
|
|
try:
|
|
self.client.list_buckets()
|
|
return True
|
|
except Exception:
|
|
return False
|