fix(upload): correct .wma MIME type to audio prefix on upload and add tests

This commit is contained in:
yiling
2026-07-05 15:57:29 +08:00
parent 8d336836cc
commit ccfcdce23c
4 changed files with 51 additions and 4 deletions
@@ -513,7 +513,10 @@ export function FileBrowser({
fileCount: 0,
type: 'file',
status: hasUrl ? 'uploading' : 'error',
mediaType: f.file.type || null,
mediaType:
f.file.name.toLowerCase().endsWith('.wma') && f.file.type?.startsWith('video/')
? f.file.type.replace(/^video\//, 'audio/')
: f.file.type || null,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
}
@@ -846,13 +849,17 @@ export function FileBrowser({
}
const fileWithId = { file, id: ulid() }
fileWithIds.push(fileWithId)
let mediaType = file.type
if (fileName.toLowerCase().endsWith('.wma') && mediaType?.startsWith('video/')) {
mediaType = mediaType.replace(/^video\//, 'audio/')
}
currentLevel.push({
name: fileName,
size: file.size,
type: 'file',
id: fileWithId.id,
children: [],
mediaType: file.type,
mediaType,
})
}
filesToUpload = fileWithIds
+3 -1
View File
@@ -139,7 +139,9 @@ export const longAudioVideoAsset: AssetInfo = {
export const SAMPLE_AUDIO_URL = '/sample-audio.mp4'
export const SAMPLE_AUDIO_DURATION = 3.0
export const SAMPLE_AUDIO_COMPUTED_TOTAL_FRAMES = Math.round(SAMPLE_AUDIO_DURATION * SAMPLE_FRAME_RATE)
export const SAMPLE_AUDIO_COMPUTED_TOTAL_FRAMES = Math.round(
SAMPLE_AUDIO_DURATION * SAMPLE_FRAME_RATE,
)
export const sampleAudioAsset: AssetInfo = {
...sampleVideoAsset,