freeleaps-service-hub/apps/central_storage/backend/application/document_hub.py

37 lines
1.1 KiB
Python

from backend.business.document_manager import (
DocumentManager,
)
class DocumentHub:
def __init__(
self,
):
self.document_manager = DocumentManager()
return
async def retrieve_document_info(self, document_id: str):
return await self.document_manager.retrieve_document_info(document_id)
async def read_document_file_as_http_media_data(self, document_id: str):
return await self.document_manager.read_document_file_as_http_media_data(
document_id
)
async def upload_document(
self, associated_with: str, file_name: str, file_data: bytes
) -> bool:
"""Upload a file
Args:
file_name: the name of the file
file (bytes): the file to be uploaded
"""
return await self.document_manager.upload_file(
associated_with, file_name, file_data
)
async def delete_documents(self, document_ids: list):
for document_id in document_ids:
await self.document_manager.delete_document(document_id)
return