v1.0.152: base64 chunks (parser expects base64)
This commit is contained in:
@@ -73,7 +73,7 @@
|
||||
<cftransaction>
|
||||
<cfquery datasource="baza">
|
||||
INSERT INTO documents (filename, mime_type, original_bytes, status)
|
||||
VALUES (<cfqueryparam value="#clientFile#" cfsqltype="cf_sql_varchar">,<cfqueryparam value="#mime#" cfsqltype="cf_sql_varchar">,decode(<cfqueryparam value="#allData#" cfsqltype="cf_sql_varchar">,'hex'),'uploaded')
|
||||
VALUES (<cfqueryparam value="#clientFile#" cfsqltype="cf_sql_varchar">,<cfqueryparam value="#mime#" cfsqltype="cf_sql_varchar">,decode(<cfqueryparam value="#allData#" cfsqltype="cf_sql_varchar">,'base64'),'uploaded')
|
||||
</cfquery>
|
||||
<cfquery name="doc" datasource="baza">
|
||||
SELECT id FROM documents WHERE filename=<cfqueryparam value="#clientFile#" cfsqltype="cf_sql_varchar"> AND status='uploaded' ORDER BY created_at DESC LIMIT 1
|
||||
|
||||
@@ -290,7 +290,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
|
||||
def _handle_upload(self):
|
||||
"""Принять файл и передать в Lucee чанками (лимит ingress ~30KB)."""
|
||||
import uuid
|
||||
import uuid, base64
|
||||
from email.parser import BytesParser
|
||||
|
||||
content_type = self.headers.get("Content-Type", "")
|
||||
@@ -333,7 +333,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
"chunk_index": i,
|
||||
"total_chunks": total,
|
||||
"filename": filename,
|
||||
"data": chunk.hex(),
|
||||
"data": base64.b64encode(chunk).decode(),
|
||||
},
|
||||
)
|
||||
if r.status_code != 200:
|
||||
@@ -481,21 +481,27 @@ class Handler(BaseHTTPRequestHandler):
|
||||
if ext not in ('docx', 'doc', 'pdf'):
|
||||
continue
|
||||
|
||||
content_hex = "\\x" + content.hex()
|
||||
import base64 as b64
|
||||
content_b64 = b64.b64encode(content).decode()
|
||||
resp = httpx.post(
|
||||
f"{LUCEE_URL}/upload.cfm",
|
||||
data={"filename": name, "data": content_hex},
|
||||
data={"filename": name, "data": content_b64},
|
||||
timeout=30
|
||||
)
|
||||
if resp.status_code == 200:
|
||||
rj = resp.json()
|
||||
if rj.get("OK"):
|
||||
results.append({
|
||||
entry = {
|
||||
"filename": name,
|
||||
"doc_id": rj.get("DOC_ID", ""),
|
||||
"contract_id": rj.get("CONTRACT_ID", ""),
|
||||
"size": len(content),
|
||||
})
|
||||
}
|
||||
# Парсинг PDF на VM
|
||||
parsed = self._parse_file(name, content)
|
||||
if parsed:
|
||||
entry["parsed"] = parsed
|
||||
results.append(entry)
|
||||
else:
|
||||
results.append({"filename": name, "error": rj.get("ERROR", "upload failed")})
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user