From 064774e0205f0375b12d57fd1a9d015de15471a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Tue, 23 Jun 2026 11:42:08 +0400 Subject: [PATCH] =?UTF-8?q?v1.0.143:=20chunked=20upload=2010KB=20=E2=80=94?= =?UTF-8?q?=20restore=20after=20Lucee=20limit=20still=20~30KB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/convert_server.py | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/deploy/convert_server.py b/deploy/convert_server.py index bf3de01..307c0b0 100755 --- a/deploy/convert_server.py +++ b/deploy/convert_server.py @@ -280,7 +280,8 @@ class Handler(BaseHTTPRequestHandler): self.wfile.write(json.dumps({"error": str(e)}, ensure_ascii=False).encode()) def _handle_upload(self): - """Принять файл и передать в Lucee (одним POST, лимиты k8s увеличены).""" + """Принять файл и передать в Lucee чанками (лимит ingress ~30KB).""" + import uuid from email.parser import BytesParser content_type = self.headers.get("Content-Type", "") @@ -308,10 +309,32 @@ class Handler(BaseHTTPRequestHandler): self._send_error_cors(400, "no file in request") return + CHUNK = 10000 # 10KB raw → 20KB hex → помещается + 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, verify=False) as client: resp = client.post( - f"{LUCEE_URL}/upload.cfm", - data={"filename": filename, "data": "\\x" + file_data.hex()}, + f"{LUCEE_URL}/chunk.cfm?action=assemble", + json={"upload_id": upload_id, "contract_id": contract_id}, ) if resp.status_code == 200: self.send_response(200) @@ -320,7 +343,7 @@ class Handler(BaseHTTPRequestHandler): self.end_headers() self.wfile.write(resp.content) else: - self._send_error_cors(502, f"Lucee error: {resp.status_code}") + self._send_error_cors(502, f"assemble failed: HTTP {resp.status_code}") def _handle_unzip_upload(self): """Распаковать ZIP и загрузить каждый файл в Lucee. Только файлы из корня архива."""