Spaces:
Sleeping
Sleeping
Update app/api/upload.py
Browse files- app/api/upload.py +3 -2
app/api/upload.py
CHANGED
|
@@ -67,8 +67,9 @@ async def upload_pdf(
|
|
| 67 |
db.commit()
|
| 68 |
db.refresh(new_document)
|
| 69 |
|
| 70 |
-
#
|
| 71 |
-
|
|
|
|
| 72 |
|
| 73 |
upload_success = storage_service.upload_file(content, storage_path)
|
| 74 |
|
|
|
|
| 67 |
db.commit()
|
| 68 |
db.refresh(new_document)
|
| 69 |
|
| 70 |
+
# Sanitize filename: replace spaces with underscores and remove special characters
|
| 71 |
+
safe_filename = "".join([c if c.isalnum() or c in "._-" else "_" for c in filename])
|
| 72 |
+
storage_path = f"uploads/user_{current_user.id}/{new_document.id}_{safe_filename}"
|
| 73 |
|
| 74 |
upload_success = storage_service.upload_file(content, storage_path)
|
| 75 |
|