fix(voiceover): strip codec parameters from uploaded recording mimetype
This commit is contained in:
parent
399f7f0bcf
commit
0674371536
1 changed files with 5 additions and 2 deletions
|
|
@ -87,7 +87,10 @@ export async function submitVoiceRecording(
|
|||
if (!(file instanceof File)) {
|
||||
return { success: false, error: "No audio file provided." };
|
||||
}
|
||||
if (!file.type.startsWith("audio/")) {
|
||||
// Browsers report MediaRecorder blobs as e.g. "audio/webm;codecs=opus" —
|
||||
// strip parameters so the base type matches the collection allowlist.
|
||||
const mimetype = file.type.split(";")[0]?.trim().toLowerCase() ?? "";
|
||||
if (!mimetype.startsWith("audio/")) {
|
||||
return { success: false, error: "Only audio files can be submitted." };
|
||||
}
|
||||
if (file.size > MAX_AUDIO_BYTES) {
|
||||
|
|
@ -103,7 +106,7 @@ export async function submitVoiceRecording(
|
|||
},
|
||||
file: {
|
||||
data: Buffer.from(await file.arrayBuffer()),
|
||||
mimetype: file.type,
|
||||
mimetype,
|
||||
name: file.name,
|
||||
size: file.size,
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue