34 lines
1013 B
Python
34 lines
1013 B
Python
"""Factory for user-scoped cloud storage backends."""
|
|
|
|
|
|
def build_cloud_backend(provider: str, credentials: dict):
|
|
if provider == "google_drive":
|
|
from storage.google_drive_backend import GoogleDriveBackend # lazy import
|
|
|
|
return GoogleDriveBackend(credentials)
|
|
|
|
if provider == "onedrive":
|
|
from storage.onedrive_backend import OneDriveBackend # lazy import
|
|
|
|
return OneDriveBackend(credentials)
|
|
|
|
if provider == "nextcloud":
|
|
from storage.nextcloud_backend import NextcloudBackend # lazy import
|
|
|
|
return NextcloudBackend(
|
|
credentials["server_url"],
|
|
credentials["username"],
|
|
credentials["password"],
|
|
)
|
|
|
|
if provider == "webdav":
|
|
from storage.webdav_backend import WebDAVBackend # lazy import
|
|
|
|
return WebDAVBackend(
|
|
credentials["server_url"],
|
|
credentials["username"],
|
|
credentials["password"],
|
|
)
|
|
|
|
raise ValueError(f"Unknown provider: {provider}")
|