mirror of
https://github.com/idrainformatica/PecFlow.git
synced 2026-06-16 12:45:42 +02:00
vboxes fix
This commit is contained in:
@@ -180,6 +180,39 @@ async def upload_outbound_eml(
|
||||
raise
|
||||
|
||||
|
||||
async def download_attachment(storage_path: str) -> bytes:
|
||||
"""
|
||||
Scarica un allegato da MinIO e restituisce i byte.
|
||||
|
||||
Args:
|
||||
storage_path: percorso oggetto MinIO (senza bucket name)
|
||||
|
||||
Returns:
|
||||
Byte del file scaricato
|
||||
|
||||
Raises:
|
||||
Exception: se il download fallisce
|
||||
"""
|
||||
client = get_minio_client()
|
||||
bucket = settings.minio_bucket
|
||||
|
||||
try:
|
||||
response = await client.get_object(
|
||||
bucket_name=bucket,
|
||||
object_name=storage_path,
|
||||
)
|
||||
data = await response.read()
|
||||
response.close()
|
||||
await response.release()
|
||||
logger.debug(
|
||||
f"Allegato scaricato: s3://{bucket}/{storage_path} ({len(data)} bytes)"
|
||||
)
|
||||
return data
|
||||
except Exception as e:
|
||||
logger.error(f"Errore download allegato {storage_path}: {e}")
|
||||
raise
|
||||
|
||||
|
||||
async def ensure_bucket_exists() -> None:
|
||||
"""Verifica che il bucket MinIO esista, altrimenti lo crea."""
|
||||
client = get_minio_client()
|
||||
|
||||
Reference in New Issue
Block a user