Jul 14 - Using CDN - Phase 1

This commit is contained in:
2026-07-14 11:49:25 -04:00
parent 42f9e4670c
commit bab564c23e
9 changed files with 180 additions and 30 deletions
+4 -5
View File
@@ -58,11 +58,10 @@ def _save_photo(file_obj, subfolder='inspection_photos'):
file_obj.seek(0)
if not any(header.startswith(m) for m in _IMAGE_MAGIC):
return None
filename = f"{uuid.uuid4().hex}.{ext}"
dest_dir = os.path.join(current_app.config['UPLOAD_FOLDER'], subfolder)
os.makedirs(dest_dir, exist_ok=True)
file_obj.save(os.path.join(dest_dir, filename))
return f"uploads/{subfolder}/{filename}"
# Write via the active storage backend (local disk or R2). Key format
# 'uploads/<subfolder>/<uuid>.<ext>' is unchanged across backends.
from app.utils import storage
return storage.save(file_obj, subfolder)
def _collect_form_responses(form_fields, existing_responses=None):