fix: correctly detect glb & gltf mimetypes during upload (#12623)
### What? The browser was incorrectly setting the mimetype for `.glb` and `.gltf` files to `application/octet-stream` when uploading when they should be receiving proper types consistent with `glb` and `gltf`. This patch adds logic to infer the correct `MIME` type for `.glb` files (`model/gltf-binary`) & `gltf` files (`model/gltf+json`) based on file extension during multipart processing, ensuring consistent MIME type detection regardless of browser behavior. Fixes #12620
This commit is contained in:
@@ -66,6 +66,11 @@ export const processMultipart: ProcessMultipart = async ({ options, request }) =
|
||||
const { encoding, filename: name, mimeType: mime } = info
|
||||
const filename = parseFileName(options, name)
|
||||
|
||||
const inferredMimeType =
|
||||
(filename && filename.endsWith('.glb') && 'model/gltf-binary') ||
|
||||
(filename && filename.endsWith('.gltf') && 'model/gltf+json') ||
|
||||
mime
|
||||
|
||||
// Define methods and handlers for upload process.
|
||||
const { cleanup, complete, dataHandler, getFilePath, getFileSize, getHash, getWritePromise } =
|
||||
options.useTempFiles
|
||||
@@ -137,7 +142,7 @@ export const processMultipart: ProcessMultipart = async ({ options, request }) =
|
||||
buffer: complete(),
|
||||
encoding,
|
||||
hash: getHash(),
|
||||
mimetype: mime,
|
||||
mimetype: inferredMimeType,
|
||||
size,
|
||||
tempFilePath: getFilePath(),
|
||||
truncated: Boolean('truncated' in file && file.truncated) || false,
|
||||
|
||||
Reference in New Issue
Block a user