Update admin.py
Browse files
admin.py
CHANGED
|
@@ -43,8 +43,8 @@ async def upload_pdf(
|
|
| 43 |
|
| 44 |
doc_id = ObjectId()
|
| 45 |
|
| 46 |
-
pdf_path = f"files/{str(doc_id)}.pdf"
|
| 47 |
-
os.makedirs("files", exist_ok=True)
|
| 48 |
with open(pdf_path, "wb") as f:
|
| 49 |
pdf_file.seek(0)
|
| 50 |
f.write(contents)
|
|
@@ -114,7 +114,7 @@ async def delete_document(document_id: str, current_user: dict = Depends(get_adm
|
|
| 114 |
if result.deleted_count == 0:
|
| 115 |
raise HTTPException(status_code=500, detail="Échec de la suppression du document")
|
| 116 |
|
| 117 |
-
pdf_path = f"files/{document_id}.pdf"
|
| 118 |
if os.path.exists(pdf_path):
|
| 119 |
try:
|
| 120 |
os.remove(pdf_path)
|
|
|
|
| 43 |
|
| 44 |
doc_id = ObjectId()
|
| 45 |
|
| 46 |
+
pdf_path = f"static/files/{str(doc_id)}.pdf"
|
| 47 |
+
os.makedirs("static/files", exist_ok=True)
|
| 48 |
with open(pdf_path, "wb") as f:
|
| 49 |
pdf_file.seek(0)
|
| 50 |
f.write(contents)
|
|
|
|
| 114 |
if result.deleted_count == 0:
|
| 115 |
raise HTTPException(status_code=500, detail="Échec de la suppression du document")
|
| 116 |
|
| 117 |
+
pdf_path = f"static/files/{document_id}.pdf"
|
| 118 |
if os.path.exists(pdf_path):
|
| 119 |
try:
|
| 120 |
os.remove(pdf_path)
|