diff --git a/site/app.py b/site/app.py index 8b6710c..ce41c69 100644 --- a/site/app.py +++ b/site/app.py @@ -142,22 +142,26 @@ class ContractsApp: # ── Загрузка base64 (JSON) ────────────────────────────────── def _upload_json(self): - """Принять файл как base64. Сохранить строкой (без декодирования — быстро).""" + """Принять файл как base64. Без JSON-парсинга — сырой разбор.""" _log("upload_entry", "start") try: - data = request.get_json(silent=True) - _log("upload_json_parsed", f"data={'yes' if data else 'no'} len={len(request.data) if request.data else 0}") - if not data: - return jsonify({"error": "Нет JSON"}), 400 + raw = request.get_data(as_text=True) + import re + m = re.search(r'"data"\s*:\s*"([^"]*)"', raw) + 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: return jsonify({"error": "Нет filename или data"}), 400 mime = mimeutil.guess_mime(filename) or "application/octet-stream" - cid = data.get("cid") # Контракт — синхронно (быстро, нужно для следующих загрузок) if not cid: diff --git a/site/templates/upload.html b/site/templates/upload.html index 906e603..7980473 100644 --- a/site/templates/upload.html +++ b/site/templates/upload.html @@ -59,7 +59,7 @@
Nubes - Сверка договоров v1.39 + Сверка договоров v1.40