diff --git a/apps/meteor/app/ui-message/client/messageBox/messageBoxAudioMessage.js b/apps/meteor/app/ui-message/client/messageBox/messageBoxAudioMessage.js index 88f7a4c03c57..e1a6c425cbcf 100644 --- a/apps/meteor/app/ui-message/client/messageBox/messageBoxAudioMessage.js +++ b/apps/meteor/app/ui-message/client/messageBox/messageBoxAudioMessage.js @@ -154,6 +154,9 @@ Template.messageBoxAudioMessage.events({ const { rid, tmid } = this; const blob = await cancelRecording(instance, rid, tmid); - await fileUpload([{ file: blob, type: 'video', name: `${t('Audio record')}.mp3` }], { input: blob }, { rid, tmid }); + const fileName = `${t('Audio record')}.mp3`; + const file = new File([blob], fileName, { type: 'audio/mpeg' }); + + await fileUpload([{ file, type: 'audio/mpeg', name: fileName }], { input: blob }, { rid, tmid }); }, }); diff --git a/apps/meteor/app/ui/client/lib/recorderjs/audioEncoder.js b/apps/meteor/app/ui/client/lib/recorderjs/audioEncoder.js index 90181e225542..81934c69c191 100644 --- a/apps/meteor/app/ui/client/lib/recorderjs/audioEncoder.js +++ b/apps/meteor/app/ui/client/lib/recorderjs/audioEncoder.js @@ -40,7 +40,10 @@ class AudioEncoder extends Emitter { handleWorkerMessage = (event) => { switch (event.data.command) { case 'end': { - const blob = new Blob(event.data.buffer, { type: 'audio/mpeg' }); + // prepend mp3 magic number to the buffer + const magicNoPrefix = new Int8Array([73, 68, 51, 3, 0, 0, 0, 0, 0, 0]); + const bufferWithMagicNo = [magicNoPrefix, ...event.data.buffer]; + const blob = new Blob(bufferWithMagicNo, { type: 'audio/mpeg' }); this.emit('encoded', blob); this.worker.terminate(); break;