27 lines
971 B
Python
27 lines
971 B
Python
from ..config import settings
|
|
from .storage_client import StorageClient, _set_storage_client
|
|
from .minio.minio_client import MinioClient
|
|
from .bunny.bunny_client import BunnyClient
|
|
|
|
|
|
def init_storage() -> None:
|
|
client: StorageClient
|
|
if settings.storage_provider == "bunny":
|
|
client = BunnyClient(
|
|
zone=settings.bunny_zone,
|
|
api_key=settings.bunny_api_key,
|
|
cdn_base_url=settings.bunny_cdn_base_url,
|
|
token_auth_key=settings.bunny_token_auth_key,
|
|
storage_endpoint=settings.bunny_storage_endpoint,
|
|
)
|
|
else:
|
|
minio = MinioClient(
|
|
endpoint_url=settings.storage_endpoint_url,
|
|
access_key=settings.storage_access_key,
|
|
secret_key=settings.storage_secret_key,
|
|
bucket=settings.storage_bucket,
|
|
api_base_url=settings.api_base_url,
|
|
)
|
|
minio.ensure_bucket_exists()
|
|
client = minio
|
|
_set_storage_client(client)
|