fix: support gltf uploads with local preview

This commit is contained in:
Tom Boullay
2026-04-27 11:07:16 +02:00
parent 078e687e86
commit 4c3a687ff8
19 changed files with 136 additions and 98 deletions
+15
View File
@@ -49,6 +49,7 @@ export async function parseMultiUpload(req: NextRequest): Promise<ParsedUpload>
}
const parsed: ParsedFile[] = []
let modelCount = 0
for (let i = 0; i < fileEntries.length; i++) {
const file = fileEntries[i]
@@ -79,10 +80,24 @@ export async function parseMultiUpload(req: NextRequest): Promise<ParsedUpload>
}
const isModel = MODEL_EXTENSIONS.has(ext)
if (isModel) {
if (filename.toLowerCase() !== 'model.gltf') {
throw new Error('Le modele doit etre nomme model.gltf')
}
modelCount += 1
}
const buffer = Buffer.from(await file.arrayBuffer())
parsed.push({ filename, buffer, isModel })
}
if (modelCount === 0) {
throw new Error('model.gltf manquant (obligatoire)')
}
if (modelCount > 1) {
throw new Error('Un seul fichier model.gltf est autorise')
}
return { folderName: safeFolderName, files: parsed, extra }
}