Implement base64 fallback for image handling when no uploader is configured (#1)

* Initial plan

* Implement base64 fallback for image handling when no uploader configured

Co-authored-by: bbbugg <80089841+bbbugg@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: bbbugg <80089841+bbbugg@users.noreply.github.com>
This commit is contained in:
Copilot
2025-08-28 16:56:04 +08:00
committed by bbbugg
co-authored by bbbugg copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
parent 4af17ce55d
commit bb6c629aef
3 changed files with 46 additions and 1 deletions
+17
View File
@@ -10,6 +10,7 @@ from pathlib import Path
import logging
from app.core.constants import DATA_URL_PATTERN, IMAGE_URL_PATTERN, VALID_IMAGE_RATIOS
from app.config.config import settings
helper_logger = logging.getLogger("app.utils")
@@ -189,3 +190,19 @@ def get_current_version(default_version: str = "0.0.0") -> str:
except IOError as e:
helper_logger.error(f"Error reading VERSION file ('{version_file}'): {e}. Using default version '{default_version}'.")
return default_version
def is_image_upload_configured() -> bool:
"""Return True only if a valid upload provider is selected and all required settings for that provider are present."""
provider = getattr(settings, "UPLOAD_PROVIDER", "").strip().lower()
if provider == "smms":
return bool(getattr(settings, "SMMS_SECRET_TOKEN", None))
if provider == "picgo":
return bool(getattr(settings, "PICGO_API_KEY", None))
if provider == "cloudflare_imgbed":
return all([
getattr(settings, "CLOUDFLARE_IMGBED_URL", None),
getattr(settings, "CLOUDFLARE_IMGBED_AUTH_CODE", None),
getattr(settings, "CLOUDFLARE_IMGBED_UPLOAD_FOLDER", None),
])
return False