Savers
Implementation
Example
from abc import ABC, abstractmethod
from dataclasses import dataclass
from io import BytesIO
import os
from enma.application.core.interfaces.saver_adapter import File, ISaverAdapter
class CustomSaver(ISaverAdapter):
def save(self, path: str, file: File) -> bool:
full_path = os.path.join(path, file.name)
try:
with open(full_path, 'wb') as f:
f.write(file.data.getvalue())
return True
except Exception as e:
print(f"Failed to save file {file.name}: {e}")
return FalseLast updated