feat: add template upload endpoint
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
import os
|
||||
from io import BytesIO
|
||||
|
||||
from minio import Minio
|
||||
from minio.error import S3Error
|
||||
|
||||
from typing import Any
|
||||
|
||||
STORAGE_BASE = os.getenv("LOCAL_STORAGE_PATH", "./data/files")
|
||||
MINIO_ENDPOINT = os.getenv("MINIO_ENDPOINT", "localhost:9000")
|
||||
@@ -29,7 +26,9 @@ def _read_local(bucket: str, file_path: str) -> bytes:
|
||||
return f.read()
|
||||
|
||||
|
||||
def get_minio_client() -> Minio:
|
||||
def get_minio_client() -> Any:
|
||||
from minio import Minio
|
||||
|
||||
return Minio(
|
||||
MINIO_ENDPOINT,
|
||||
access_key=MINIO_ACCESS_KEY,
|
||||
@@ -45,8 +44,6 @@ def ensure_bucket(bucket_name: str) -> bool:
|
||||
if not client.bucket_exists(bucket_name):
|
||||
client.make_bucket(bucket_name)
|
||||
return True
|
||||
except S3Error:
|
||||
return False
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
@@ -64,8 +61,6 @@ def upload_file(bucket: str, file_path: str, content: bytes) -> str:
|
||||
content_type="application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
)
|
||||
return f"minio://{bucket}/{file_path}"
|
||||
except S3Error:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -83,8 +78,6 @@ def download_file(bucket: str, file_path: str) -> bytes:
|
||||
finally:
|
||||
response.close()
|
||||
response.release_conn()
|
||||
except S3Error:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user