Spaces:
Runtime error
Runtime error
Commit ·
6c3783f
1
Parent(s): aa75b88
Fix: upload PDF via PUT (API rejects POST)
Browse files- backend/worker/worker.py +3 -3
backend/worker/worker.py
CHANGED
|
@@ -11,7 +11,7 @@ def _upload_pdf_to_api(pdf_id, pdf_path, pdf_name):
|
|
| 11 |
url = base.rstrip("/") + "/api/pdf/" + str(pdf_id)
|
| 12 |
print(f"[worker] uploading pdf_id={pdf_id} to {url}")
|
| 13 |
with open(pdf_path, "rb") as f:
|
| 14 |
-
r = requests.
|
| 15 |
url,
|
| 16 |
files={"file": (f"{pdf_id}.pdf", f, "application/pdf")},
|
| 17 |
data={"pdf_name": pdf_name},
|
|
@@ -162,7 +162,7 @@ def _process_train_label(gmail: GmailClient, s: Settings, root: Path) -> None:
|
|
| 162 |
try:
|
| 163 |
if PDF_TRAINER_API_BASE:
|
| 164 |
with open(stored_pdf_path, "rb") as f:
|
| 165 |
-
r = requests.
|
| 166 |
f"{PDF_TRAINER_API_BASE.rstrip('/')}/api/pdf/{pdf_id}",
|
| 167 |
files={"file": (f"{pdf_id}.pdf", f, "application/pdf")},
|
| 168 |
data={"pdf_name": filename},
|
|
@@ -179,7 +179,7 @@ def _process_train_label(gmail: GmailClient, s: Settings, root: Path) -> None:
|
|
| 179 |
try:
|
| 180 |
if PDF_TRAINER_API_BASE:
|
| 181 |
with open(stored_pdf_path, "rb") as f:
|
| 182 |
-
requests.
|
| 183 |
f"{PDF_TRAINER_API_BASE.rstrip('/')}/api/pdf/{pdf_id}",
|
| 184 |
files={"file": (f"{pdf_id}.pdf", f, "application/pdf")},
|
| 185 |
data={"pdf_name": filename},
|
|
|
|
| 11 |
url = base.rstrip("/") + "/api/pdf/" + str(pdf_id)
|
| 12 |
print(f"[worker] uploading pdf_id={pdf_id} to {url}")
|
| 13 |
with open(pdf_path, "rb") as f:
|
| 14 |
+
r = requests.put(
|
| 15 |
url,
|
| 16 |
files={"file": (f"{pdf_id}.pdf", f, "application/pdf")},
|
| 17 |
data={"pdf_name": pdf_name},
|
|
|
|
| 162 |
try:
|
| 163 |
if PDF_TRAINER_API_BASE:
|
| 164 |
with open(stored_pdf_path, "rb") as f:
|
| 165 |
+
r = requests.put(
|
| 166 |
f"{PDF_TRAINER_API_BASE.rstrip('/')}/api/pdf/{pdf_id}",
|
| 167 |
files={"file": (f"{pdf_id}.pdf", f, "application/pdf")},
|
| 168 |
data={"pdf_name": filename},
|
|
|
|
| 179 |
try:
|
| 180 |
if PDF_TRAINER_API_BASE:
|
| 181 |
with open(stored_pdf_path, "rb") as f:
|
| 182 |
+
requests.put(
|
| 183 |
f"{PDF_TRAINER_API_BASE.rstrip('/')}/api/pdf/{pdf_id}",
|
| 184 |
files={"file": (f"{pdf_id}.pdf", f, "application/pdf")},
|
| 185 |
data={"pdf_name": filename},
|