v1.0.178: унификация ZIP. addZipFile → base64→File→addRegularFile (единый путь). confirm() при дубликате. unzip.py — только распаковка, без БД.
This commit is contained in:
@@ -1,20 +1,17 @@
|
||||
"""Unzip service — extract files from ZIP archive."""
|
||||
import zipfile, io, base64, json
|
||||
"""Unzip service — extract files from ZIP archive (no DB, no parse)."""
|
||||
import zipfile, io, base64
|
||||
|
||||
|
||||
def handle_unzip(rfile, content_length):
|
||||
"""Parse ZIP upload, return list of extracted files."""
|
||||
"""Parse ZIP upload, return list of extracted files as base64."""
|
||||
body = rfile.read(content_length)
|
||||
|
||||
# Find file data in raw multipart
|
||||
# Simple approach: find ZIP bytes after header
|
||||
idx = body.find(b"\r\n\r\n")
|
||||
if idx < 0:
|
||||
return {"ok": False, "error": "invalid multipart"}
|
||||
|
||||
# Find first boundary end
|
||||
raw = body[idx + 4:]
|
||||
# Find the actual ZIP data (after Content-Disposition etc)
|
||||
zip_start = raw.find(b"PK\x03\x04")
|
||||
if zip_start < 0:
|
||||
return {"ok": False, "error": "not a ZIP file"}
|
||||
|
||||
Reference in New Issue
Block a user