fix: support gltf uploads with local preview
This commit is contained in:
@@ -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 }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user