From 800ae657f62628aff9a2a65c8be8a076ce068790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Tue, 23 Jun 2026 11:33:21 +0400 Subject: [PATCH] =?UTF-8?q?v1.0.142:=20direct=20upload=20=E2=80=94=20one?= =?UTF-8?q?=20piece,=20Lucee=20k8s=20limits=20increased?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/convert_server.py | 36 +++++------------------------------- 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/deploy/convert_server.py b/deploy/convert_server.py index 63dedda..bf3de01 100755 --- a/deploy/convert_server.py +++ b/deploy/convert_server.py @@ -280,8 +280,7 @@ class Handler(BaseHTTPRequestHandler): self.wfile.write(json.dumps({"error": str(e)}, ensure_ascii=False).encode()) def _handle_upload(self): - """Принять файл и передать в Lucee чанками (обходит лимит тела запроса).""" - import uuid + """Принять файл и передать в Lucee (одним POST, лимиты k8s увеличены).""" from email.parser import BytesParser content_type = self.headers.get("Content-Type", "") @@ -301,7 +300,6 @@ class Handler(BaseHTTPRequestHandler): filename = fn file_data = part.get_payload(decode=True) else: - # Может быть поле contract_id disp = part.get("Content-Disposition", "") if "name=\"contract_id\"" in disp: contract_id = part.get_payload(decode=True).decode("utf-8", errors="ignore").strip() @@ -310,34 +308,10 @@ class Handler(BaseHTTPRequestHandler): self._send_error_cors(400, "no file in request") return - # Режем на чанки (новый HTTP/2 connection на каждый — Lucee сбрасывает стрим) - CHUNK = 20000 - upload_id = str(uuid.uuid4()) - raw = file_data - total = (len(raw) + CHUNK - 1) // CHUNK - - for i in range(total): - chunk = raw[i*CHUNK:(i+1)*CHUNK] - with httpx.Client(http2=True, timeout=30, verify=False) as client: - r = client.post( - f"{LUCEE_URL}/chunk.cfm?action=put", - json={ - "upload_id": upload_id, - "chunk_index": i, - "total_chunks": total, - "filename": filename, - "data": chunk.hex(), - }, - ) - if r.status_code != 200: - self._send_error_cors(502, f"chunk {i+1}/{total} failed: HTTP {r.status_code}") - return - - # Собрать чанки - with httpx.Client(http2=True, timeout=60) as client: + with httpx.Client(http2=True, timeout=60, verify=False) as client: resp = client.post( - f"{LUCEE_URL}/chunk.cfm?action=assemble", - json={"upload_id": upload_id, "contract_id": contract_id}, + f"{LUCEE_URL}/upload.cfm", + data={"filename": filename, "data": "\\x" + file_data.hex()}, ) if resp.status_code == 200: self.send_response(200) @@ -346,7 +320,7 @@ class Handler(BaseHTTPRequestHandler): self.end_headers() self.wfile.write(resp.content) else: - self._send_error_cors(502, f"assemble failed: HTTP {resp.status_code}") + self._send_error_cors(502, f"Lucee error: {resp.status_code}") def _handle_unzip_upload(self): """Распаковать ZIP и загрузить каждый файл в Lucee. Только файлы из корня архива."""