Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bowenliang123 committed Oct 8, 2024
1 parent 58449ff commit bf3f1ac
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
21 changes: 11 additions & 10 deletions api/extensions/ext_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from configs import dify_config
from extensions.storage.base_storage import BaseStorage
from extensions.storage.storage_type import StorageType


class Storage:
Expand All @@ -19,43 +20,43 @@ def init_app(self, app: Flask):
@staticmethod
def get_storage_factory(storage_type: str) -> type[BaseStorage]:
match storage_type:
case "s3":
case StorageType.S3:
from extensions.storage.s3_storage import S3Storage

return S3Storage
case "azure-blob":
case StorageType.AZURE_BLOB:
from extensions.storage.azure_storage import AzureStorage

return AzureStorage
case "aliyun-oss":
case StorageType.ALIYUN_OSS:
from extensions.storage.aliyun_storage import AliyunStorage

return AliyunStorage
case "google-storage":
case StorageType.GOOGLE_STORAGE:
from extensions.storage.google_storage import GoogleStorage

return GoogleStorage
case "tencent-cos":
case StorageType.TENCENT_COS:
from extensions.storage.tencent_storage import TencentStorage

return TencentStorage
case "oci-storage":
case StorageType.OCI_STORAGE:
from extensions.storage.oci_storage import OCIStorage

return OCIStorage
case "huawei-obs":
case StorageType.HUAWEI_OBS:
from extensions.storage.huawei_storage import HuaweiStorage

return HuaweiStorage
case "baidu-obs":
case StorageType.BAIDU_OBS:
from extensions.storage.baidu_storage import BaiduStorage

return BaiduStorage
case "volcengine-tos":
case StorageType.VOLCENGINE_TOS:
from extensions.storage.volcengine_storage import VolcengineStorage

return VolcengineStorage
case _:
case StorageType.LOCAL | _:
from extensions.storage.local_storage import LocalStorage

return LocalStorage
Expand Down
14 changes: 14 additions & 0 deletions api/extensions/storage/storage_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from enum import Enum


class StorageType(str, Enum):
S3 = "s3"
AZURE_BLOB = "azure-blob"
ALIYUN_OSS = "aliyun-oss"
GOOGLE_STORAGE = "google-storage"
TENCENT_COS = "tencent-cos"
OCI_STORAGE = "oci-storage"
HUAWEI_OBS = "huawei-obs"
BAIDU_OBS = "baidu-obs"
VOLCENGINE_TOS = "volcengine-tos"
LOCAL = "local"

0 comments on commit bf3f1ac

Please sign in to comment.