fix: update upload_scanner to use Rust info-privacy-rs service
- Change target URL to port 8001 (RKNN-accelerated Rust service)
- Fix redact API call: pass config as JSON field instead of form data
Rust API requires: -F 'config={"redact_types":["id_card",...]}'
- Discovery: info-privacy-rs already running on device with full
PDF/DOCX/XLSX support and RKNN face detection
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -12,7 +12,7 @@ from dataclasses import dataclass
|
||||
|
||||
import httpx
|
||||
|
||||
_INFO_PRIVACY_BASE = "http://localhost:8000/api/v1"
|
||||
_INFO_PRIVACY_BASE = "http://localhost:8001/api/v1" # Rust info-privacy-rs (RKNN accelerated)
|
||||
_REDACT_TYPES = ["id_card", "phone", "bank_card", "email", "license_plate", "name", "address", "face"]
|
||||
|
||||
|
||||
@@ -59,11 +59,12 @@ async def scan_and_redact(filename: str, raw_bytes: bytes) -> ScanResult:
|
||||
original_hash=original_hash,
|
||||
)
|
||||
|
||||
# Step 2: 脱敏
|
||||
# Step 2: 脱敏(Rust API 需要 config JSON 字段指定脱敏类型)
|
||||
import json as _json
|
||||
redact_resp = await client.post(
|
||||
f"{_INFO_PRIVACY_BASE}/redact",
|
||||
files={"file": (filename, io.BytesIO(raw_bytes))},
|
||||
data={"redact_types": list(summary.keys())},
|
||||
data={"config": _json.dumps({"redact_types": list(summary.keys())})},
|
||||
)
|
||||
if redact_resp.status_code != 200:
|
||||
return ScanResult(
|
||||
|
||||
Reference in New Issue
Block a user