US-1: Asset Import Pipeline — glTF upload endpoint with metadata extraction #27

Merged
reviewer-bot merged 5 commits from agent/25d5046bb30c into main 2026-08-19 13:58:16 +00:00
Showing only changes of commit 54abe7ee96 - Show all commits
+2 -4
View File
@@ -15,6 +15,7 @@ from typing import Any, Optional
# GLB binary header magic bytes ("glTF"). # GLB binary header magic bytes ("glTF").
_GLB_MAGIC = b"glTF" _GLB_MAGIC = b"glTF"
_GLB_MAGIC_INT = 0x46546C67 # b"glTF" interpreted as little-endian uint32
_GLB_JSON_CHUNK_TYPE = 0x4E4F534A # "JSON" _GLB_JSON_CHUNK_TYPE = 0x4E4F534A # "JSON"
_GLB_BIN_CHUNK_TYPE = 0x004E4942 # "BIN\0" _GLB_BIN_CHUNK_TYPE = 0x004E4942 # "BIN\0"
@@ -48,7 +49,7 @@ def _parse_glb(content: bytes) -> dict[str, Any]:
raise ValueError("GLB file is too short") raise ValueError("GLB file is too short")
magic, _version, _length = struct.unpack_from("<III", content, 0) magic, _version, _length = struct.unpack_from("<III", content, 0)
if magic != _GLB_MAGIC: if magic != _GLB_MAGIC_INT:
raise ValueError("invalid GLB magic") raise ValueError("invalid GLB magic")
offset = 12 offset = 12
@@ -79,9 +80,6 @@ def _parse_glb(content: bytes) -> dict[str, Any]:
def _parse_gltf_json(content: bytes) -> dict[str, Any]: def _parse_gltf_json(content: bytes) -> dict[str, Any]:
"""Parse a plain .gltf JSON file.""" """Parse a plain .gltf JSON file."""
stripped = content.lstrip() stripped = content.lstrip()
if not stripped.startswith(b"{"):
raise ValueError("glTF JSON does not start with an object")
try: try:
payload = json.loads(stripped.decode("utf-8")) payload = json.loads(stripped.decode("utf-8"))
except (ValueError, UnicodeDecodeError) as exc: except (ValueError, UnicodeDecodeError) as exc: