1
0
Fork 0

fix(voiceover): strip codec parameters from uploaded recording mimetype

This commit is contained in:
Jason Fraley 2026-09-07 00:52:26 -04:00
parent 399f7f0bcf
commit 0674371536

View file

@ -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,
},