fix: photo upload date parameter parsing
Problem: Photos were always getting NULL date instead of form date,
causing frontend to fallback to created timestamp (today).
Root cause: FastAPI requires Form() wrapper for form fields when
mixing with File() parameters. Without it, the date parameter was
treated as query parameter and always received empty string.
Solution:
- Import Form from fastapi
- Change date parameter from str="" to str=Form("")
- Return photo_date instead of date in response (consistency)
Now photos correctly use the date from the upload form and can be
backdated when uploading later.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
ef27660fc8
commit
0278a8e4a6
|
|
@ -9,7 +9,7 @@ import logging
|
|||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import APIRouter, UploadFile, File, Header, HTTPException, Depends
|
||||
from fastapi import APIRouter, UploadFile, File, Form, Header, HTTPException, Depends
|
||||
from fastapi.responses import FileResponse
|
||||
import aiofiles
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ PHOTOS_DIR.mkdir(parents=True, exist_ok=True)
|
|||
|
||||
|
||||
@router.post("")
|
||||
async def upload_photo(file: UploadFile=File(...), date: str="",
|
||||
async def upload_photo(file: UploadFile=File(...), date: str=Form(""),
|
||||
x_profile_id: Optional[str]=Header(default=None), session: dict=Depends(require_auth)):
|
||||
"""Upload progress photo."""
|
||||
pid = get_pid(x_profile_id)
|
||||
|
|
@ -62,7 +62,7 @@ async def upload_photo(file: UploadFile=File(...), date: str="",
|
|||
# Phase 2: Increment usage counter
|
||||
increment_feature_usage(pid, 'photos')
|
||||
|
||||
return {"id":fid,"date":date}
|
||||
return {"id":fid,"date":photo_date}
|
||||
|
||||
|
||||
@router.get("/{fid}")
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user