feat(hosted-file): implement intelligent ID resolution for V3 download action
- Updates download_file_action to automatically resolve container IDs (like event_file) to the underlying hosted_file. - Updates GUIDE__V3_FRONTEND_API.md to document the 'ID Vision' standard for downloads. - Resolves 404 errors observed when frontend passed event_file IDs to the hosted_file download endpoint.
This commit is contained in:
@@ -209,7 +209,17 @@ async def download_file_action(
|
||||
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="Authentication required or invalid site_key.")
|
||||
|
||||
# 2. Resolve File Record
|
||||
# ID Vision: Attempt to resolve the ID.
|
||||
# If not found in hosted_file, check if it's an event_file ID that we can resolve to a hosted_file.
|
||||
resolved_id = redis_lookup_id_random(record_id_random=hosted_file_id, table_name='hosted_file')
|
||||
|
||||
if not resolved_id:
|
||||
log.info(f"ID {hosted_file_id} not found in hosted_file. Checking event_file...")
|
||||
if ef_id := redis_lookup_id_random(record_id_random=hosted_file_id, table_name='event_file'):
|
||||
if ef_rec := sql_select(sql="SELECT hosted_file_id FROM event_file WHERE id = :id", data={'id': ef_id}):
|
||||
resolved_id = ef_rec.get('hosted_file_id')
|
||||
log.info(f"Resolved event_file {hosted_file_id} to hosted_file {resolved_id}")
|
||||
|
||||
if not resolved_id:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Hosted file record not found.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user