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 -10
View File
@@ -85,16 +85,10 @@ def upload_photo():
else:
subfolder = 'inspection_photos'
ext = file_obj.filename.rsplit('.', 1)[-1].lower()
filename = f'{uuid.uuid4().hex}.{ext}'
dest_dir = os.path.join(current_app.config['UPLOAD_FOLDER'], subfolder)
os.makedirs(dest_dir, exist_ok=True)
dest_path = os.path.join(dest_dir, filename)
file_obj.save(dest_path)
server_path = 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
server_path = storage.save(file_obj, subfolder)
logger.info('API PHOTOS | uploaded | entity_type=%s | path=%s | user=%s',
entity_type, server_path, user.username)