45 lines
1.8 KiB
Diff
45 lines
1.8 KiB
Diff
diff --git a/backend/open_webui/storage/provider.py b/backend/open_webui/storage/provider.py
|
|
index 261f010..048ea4b 100644
|
|
--- a/backend/open_webui/storage/provider.py
|
|
+++ b/backend/open_webui/storage/provider.py
|
|
@@ -6,14 +6,6 @@ import shutil
|
|
from abc import ABC, abstractmethod
|
|
from typing import BinaryIO, Dict, Tuple
|
|
|
|
-import boto3
|
|
-from azure.core.exceptions import ResourceNotFoundError
|
|
-from azure.identity import DefaultAzureCredential
|
|
-from azure.storage.blob import BlobServiceClient
|
|
-from botocore.config import Config
|
|
-from botocore.exceptions import ClientError
|
|
-from google.cloud import storage
|
|
-from google.cloud.exceptions import GoogleCloudError, NotFound
|
|
from open_webui.config import (
|
|
AZURE_STORAGE_CONTAINER_NAME,
|
|
AZURE_STORAGE_ENDPOINT,
|
|
@@ -335,10 +327,24 @@ def get_storage_provider(storage_provider: str):
|
|
if storage_provider == 'local':
|
|
Storage = LocalStorageProvider()
|
|
elif storage_provider == 's3':
|
|
+ global boto3, Config, ClientError
|
|
+ import boto3
|
|
+ from botocore.config import Config
|
|
+ from botocore.exceptions import ClientError
|
|
+
|
|
Storage = S3StorageProvider()
|
|
elif storage_provider == 'gcs':
|
|
+ global storage, GoogleCloudError, NotFound
|
|
+ from google.cloud import storage
|
|
+ from google.cloud.exceptions import GoogleCloudError, NotFound
|
|
+
|
|
Storage = GCSStorageProvider()
|
|
elif storage_provider == 'azure':
|
|
+ global ResourceNotFoundError, DefaultAzureCredential, BlobServiceClient
|
|
+ from azure.core.exceptions import ResourceNotFoundError
|
|
+ from azure.identity import DefaultAzureCredential
|
|
+ from azure.storage.blob import BlobServiceClient
|
|
+
|
|
Storage = AzureStorageProvider()
|
|
else:
|
|
raise RuntimeError(f'Unsupported storage provider: {storage_provider}')
|