"""Storage backends for the api app.""" from django.conf import settings from django.core.files.storage import FileSystemStorage class IdCardStorage(FileSystemStorage): """Filesystem storage for uploaded ID/passport photos. Location/URL come from settings (IDCARD_STORAGE_ROOT / IDCARD_STORAGE_URL) so the directory can be bind-mounted as a persistent volume in production. """ def __init__(self, **kwargs): kwargs.setdefault("location", settings.IDCARD_STORAGE_ROOT) kwargs.setdefault("base_url", settings.IDCARD_STORAGE_URL) super().__init__(**kwargs) def idcard_storage(): """Callable referenced by the model field. Using a named callable keeps the resolved location out of migrations, so changing the mount path never requires a new migration. """ return IdCardStorage()