сырой разбор JSON (regex, без get_json), v1.40
This commit is contained in:
+13
-9
@@ -142,22 +142,26 @@ class ContractsApp:
|
|||||||
# ── Загрузка base64 (JSON) ──────────────────────────────────
|
# ── Загрузка base64 (JSON) ──────────────────────────────────
|
||||||
|
|
||||||
def _upload_json(self):
|
def _upload_json(self):
|
||||||
"""Принять файл как base64. Сохранить строкой (без декодирования — быстро)."""
|
"""Принять файл как base64. Без JSON-парсинга — сырой разбор."""
|
||||||
_log("upload_entry", "start")
|
_log("upload_entry", "start")
|
||||||
try:
|
try:
|
||||||
data = request.get_json(silent=True)
|
raw = request.get_data(as_text=True)
|
||||||
_log("upload_json_parsed", f"data={'yes' if data else 'no'} len={len(request.data) if request.data else 0}")
|
import re
|
||||||
if not data:
|
m = re.search(r'"data"\s*:\s*"([^"]*)"', raw)
|
||||||
return jsonify({"error": "Нет JSON"}), 400
|
if not m:
|
||||||
|
return jsonify({"error": "Нет data"}), 400
|
||||||
|
b64 = m.group(1)
|
||||||
|
|
||||||
|
m = re.search(r'"filename"\s*:\s*"([^"]*)"', raw)
|
||||||
|
filename = m.group(1) if m else ""
|
||||||
|
|
||||||
|
m = re.search(r'"cid"\s*:\s*"([^"]*)"', raw)
|
||||||
|
cid = m.group(1) if m else None
|
||||||
|
|
||||||
filename = data.get("filename", "")
|
|
||||||
b64 = data.get("data", "")
|
|
||||||
_log("upload", f"file={filename} b64={len(b64) if b64 else 0}")
|
|
||||||
if not filename or not b64:
|
if not filename or not b64:
|
||||||
return jsonify({"error": "Нет filename или data"}), 400
|
return jsonify({"error": "Нет filename или data"}), 400
|
||||||
|
|
||||||
mime = mimeutil.guess_mime(filename) or "application/octet-stream"
|
mime = mimeutil.guess_mime(filename) or "application/octet-stream"
|
||||||
cid = data.get("cid")
|
|
||||||
|
|
||||||
# Контракт — синхронно (быстро, нужно для следующих загрузок)
|
# Контракт — синхронно (быстро, нужно для следующих загрузок)
|
||||||
if not cid:
|
if not cid:
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<div class="topbar">
|
<div class="topbar">
|
||||||
<img src="{{ url_for('static', filename='nubes-logo.svg') }}" alt="Nubes">
|
<img src="{{ url_for('static', filename='nubes-logo.svg') }}" alt="Nubes">
|
||||||
<span class="title">Сверка договоров <span style="font-weight:400;color:var(--muted);font-size:12px;">v1.39</span></span>
|
<span class="title">Сверка договоров <span style="font-weight:400;color:var(--muted);font-size:12px;">v1.40</span></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
|
|||||||
Reference in New Issue
Block a user