Help

Upload .wav file to airtable from html javascript recording

266 1
cancel
Showing results for 
Search instead for 
Did you mean: 
btener
4 - Data Explorer
4 - Data Explorer

I have a javascript code that basically displays a recording menu that allows you to record your voice, and then I added that on stop you can click to send the file to airtable. But I keep getting 422 error. I read somewhere that when sending attachment it need to be on publicly available url. Any ideas how can I solve this?

$.ajax({
        url: apiUrl,
        type: 'PUT',
        headers: {
          'Authorization': `Bearer ${apiKey}`,
          'Content-Type': 'multipart/form-data',
        },
        data: formData,
        processData: false,
        contentType: false,
        success: (response) => {
          console.log('Audio uploaded to Airtable successfully:', response);
        },
        error: (error) => {
          console.error('Error uploading audio to Airtable:', error);
        }
      });
    }
 --------
 const formData = new FormData();
      formData.append('Attachments', new File(audioChunks, 'audio.wav'));
---------
My field's name is "attachments"
------------
 audioPlayer.src = URL.createObjectURL(audioBlob);
 
 
1 Reply 1

You are correct that the only way to create a new attachment in Airtable using code is by using a file at a publicly accessible URL. Since you have a file blob and not a publicly accessibld URL, you need to upload the blob somewhere that will give you a publicly accessible URL, such as Cloudinary or some other CDN service that accepts a blob.