0

Reference to this conversation's last answer: Question-Answer-Session I am unable to debug and fix files and run code correctly. I see that it is flagged as helpful and correct. Can someone help me understand file structure needed to fix this? I am unable to run this code.

  • MAIN ISSUE: I am trying to save recorded audio to server.
  • My BLOB url is: blob:http%3A//localhost/7bc08d6c-8862-45b5-b567-040fd14ef4aa
  • I am using recorder.js

Thanks!

Community
  • 1
  • 1
  • 1
    Which piece of the code exactly are you having trouble with? Can you show us what you've tried? – Paul S. Feb 13 '14 at 18:07
  • function upload(blob) { var xhr=new XMLHttpRequest(); xhr.onload=function(e) { if(this.readyState === 4) { console.log("Server returned: ",e.target.responseText)); } }; var fd=new FormData(); fd.append("that_random_filename.wav",blob); xhr.open("POST","",true); xhr.send(fd); } – Saggy Coder Feb 13 '14 at 18:13
  • i tried by changing values but no use – Saggy Coder Feb 13 '14 at 18:14
  • You need a blob not a blob url. – Musa Feb 13 '14 at 18:27

1 Answers1

0
const constructUploadData = (file: any, data: { audioQueueId: string | Blob; fileName: string | Blob }) => {
    const formData = new FormData();
    formData.append('audioQueueId', data.audioQueueId);
    formData.append('fileName', data.fileName);
    if (file) {
        formData.append('file', new Blob(file ? [file] : [], { type: file.type }));
    }
    return formData;
};
     


const uploadAudioInBackground = (file: any, data: any) => {
    return axios.post(`clip/upload`, constructUploadData(file, data), {
        headers: { 'Content-Type': 'multipart/form-data' }
    });
};
Sanjay
  • 83
  • 2
  • 11