mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-02 12:05:54 +00:00
* Initial plan * Add S3 object storage support with provider selection Co-authored-by: RockChinQ <45992437+RockChinQ@users.noreply.github.com> * Fix lint issue: remove unused MagicMock import Co-authored-by: RockChinQ <45992437+RockChinQ@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: RockChinQ <45992437+RockChinQ@users.noreply.github.com>
31 lines
867 B
Python
31 lines
867 B
Python
from __future__ import annotations
|
|
|
|
|
|
from ..core import app
|
|
from . import provider
|
|
from .providers import localstorage, s3storage
|
|
|
|
|
|
class StorageMgr:
|
|
"""Storage manager"""
|
|
|
|
ap: app.Application
|
|
|
|
storage_provider: provider.StorageProvider
|
|
|
|
def __init__(self, ap: app.Application):
|
|
self.ap = ap
|
|
|
|
async def initialize(self):
|
|
storage_config = self.ap.instance_config.data.get('storage', {})
|
|
storage_type = storage_config.get('use', 'local')
|
|
|
|
if storage_type == 's3':
|
|
self.storage_provider = s3storage.S3StorageProvider(self.ap)
|
|
self.ap.logger.info('Initialized S3 storage backend.')
|
|
else:
|
|
self.storage_provider = localstorage.LocalStorageProvider(self.ap)
|
|
self.ap.logger.info('Initialized local storage backend.')
|
|
|
|
await self.storage_provider.initialize()
|