You've already forked RekomenciBackend
feature: add s3
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
from collections.abc import AsyncIterable
|
||||
|
||||
from aioboto3.session import Session
|
||||
from dishka import Provider, Scope, provide
|
||||
from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession, create_async_engine
|
||||
|
||||
from template_project.web_api.configuration import DatabaseConfiguration
|
||||
from template_project.adapters.s3_storage import AioBoto3ClientLike
|
||||
from template_project.web_api.configuration import DatabaseConfiguration, S3Config
|
||||
|
||||
|
||||
class ConnectionProvider(Provider):
|
||||
@@ -21,3 +23,15 @@ class ConnectionProvider(Provider):
|
||||
)
|
||||
async with session:
|
||||
yield session
|
||||
|
||||
@provide(scope=Scope.APP)
|
||||
async def s3_client(self, config: S3Config) -> AsyncIterable[AioBoto3ClientLike]:
|
||||
session = Session() # type: ignore[no-untyped-call]
|
||||
|
||||
async with session.client(
|
||||
"s3",
|
||||
endpoint_url=config.endpoint_url,
|
||||
aws_access_key_id=config.access_key,
|
||||
aws_secret_access_key=config.secret_key,
|
||||
) as s3_client:
|
||||
yield s3_client
|
||||
|
||||
Reference in New Issue
Block a user