Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -191,6 +191,7 @@ async def health_check():
|
|
| 191 |
async def upload_pdf(
|
| 192 |
file: UploadFile = File(...),
|
| 193 |
user_id: str = Depends(get_current_user),
|
|
|
|
| 194 |
background_tasks: BackgroundTasks = None
|
| 195 |
):
|
| 196 |
"""
|
|
@@ -220,8 +221,18 @@ async def upload_pdf(
|
|
| 220 |
with open(tmp_path, 'wb') as f:
|
| 221 |
f.write(content)
|
| 222 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 223 |
# Create persistent job and return immediately
|
| 224 |
-
job = job_manager.create_job(user_id=user_id, filename=file.filename, file_path=tmp_path)
|
| 225 |
|
| 226 |
return UploadResponse(
|
| 227 |
document_id=job['id'],
|
|
|
|
| 191 |
async def upload_pdf(
|
| 192 |
file: UploadFile = File(...),
|
| 193 |
user_id: str = Depends(get_current_user),
|
| 194 |
+
x_api_key: Optional[str] = Header(None, alias="X-API-KEY"),
|
| 195 |
background_tasks: BackgroundTasks = None
|
| 196 |
):
|
| 197 |
"""
|
|
|
|
| 221 |
with open(tmp_path, 'wb') as f:
|
| 222 |
f.write(content)
|
| 223 |
|
| 224 |
+
# Try to resolve username from HF user manager (if available)
|
| 225 |
+
username = None
|
| 226 |
+
try:
|
| 227 |
+
if hf_user_manager and hf_user_manager.enabled and x_api_key:
|
| 228 |
+
found = hf_user_manager.get_user_by_api_key(x_api_key)
|
| 229 |
+
if found:
|
| 230 |
+
username = found[0]
|
| 231 |
+
except Exception:
|
| 232 |
+
username = None
|
| 233 |
+
|
| 234 |
# Create persistent job and return immediately
|
| 235 |
+
job = job_manager.create_job(user_id=user_id, filename=file.filename, file_path=tmp_path, username=username)
|
| 236 |
|
| 237 |
return UploadResponse(
|
| 238 |
document_id=job['id'],
|