Next.js Discord

Discord Forum

How Do I get an MP3 File from an Object URL

Answered
Bald Eagle posted this in #help-forum
Open in Discord
Bald EagleOP
The following is my current strategy but I am at a loss for how to implement this properly.
const mp3file = fetch(audioUrl).then(r => r.blob).then(blob => new File([blob], "a.mp3")) .
This results in the syntax error Type '() => Promise<Blob>' is not assignable to type 'BlobPart'.. Does anyone know how to convert this blob from the then statement to a valid blob part that I can use to create an audio file?
Answered by Bald Eagle
For those that are curious:
const file = new File([audioBlob], "recording.mp3")
const formData = new FormData();
formData.append('file', file);
View full answer

2 Replies

Bald EagleOP
Fixed
Bald EagleOP
For those that are curious:
const file = new File([audioBlob], "recording.mp3")
const formData = new FormData();
formData.append('file', file);
Answer