Recorded audio to GDrive / Error when decoding base64 strings

Struggling after hours trying to capture an error I'm getting when uploading audio files after conversion to base64.
Tanks to the help of Tim& Juan I managed to get thing running good for images. For the audios it looks like the conversion is not done properly.
Basically after tracking it appears that all is well done, the script gets what has to be received and when using Utilities.base64Decode(e.parameters.text) where text is just the string sent by the Web component, the response content is "unable to decode..."
Anyone with knowledge ?
This will be much appreciated.
All the material is here (especially for the aia) : access

Hi Moon

You don't seem to use any safeguard on the App side, to know that the send was successful. Per your Topic Title, are you sending to your Google Drive? The code seems more related to sending to a Google Sheet, a completely different task.....

Hi Chris
Thanks for your prompt answer.
You are right at this level of dev I'm doing a minimalist approach and anyway still have to learn more.
The script you see is the one I'm using for uploading pictures. According to Juan (KIO4) it's supposed to work for any file as soon as we can convert them to base64.
my scripts to feed GoogleSheets are different.
Does it help ?

First things first - are you using Google Sheets or Google Drive?

Just Google Drive.
BTW the decoding works perfectly within the App. it's only the decoding from the server side that fails.

Google drive does not even need a Base64 string, it is just like a drive on your PC - it stores files. The App sends them and retrieves them.

Sunny Gupta has a Google Drive extension that should make life easier for you:

Thanks for pointing me towards that extension. I'll definitely review before buying. After a quick look the only thing that may kill me is the credentials from Google hope it's not going to be a hassel. Thx again.

Looking at your blocks, you have

  • for the mimetype value you only have mp3 instead of data: audio/3gpp (or data: audio/mp3 if you want to name your 3gp to mp3)

see my blocks below

I have just run a test aia project on the method without any issues. I can, make and save a sound recording to the ASD, convert a sound recording to base64, upload it to google drive as a file, download the file, and play it back. This is on an Android 12 device, using companion 2.62, and the latest version of KIO4_base64 extension.




SCRIPT (note that I have a parameter for the folderID)




ulsound.aia (27.2 KB)

I split the process up into sections, with button actions and labels in order to observe progress.

I suggest you do something similar to debug your app, in order to identify where things are going wrong.

Note: the binary file (e.g. sound recording) will be converted to base64 at some point in any upload process used, it is just with this method you actual see it happening!



Thank you so much Tim.
Using your blocks it appears that the only point is the removal of the carriage return \n from the returned base64 string.
Appreciated much.

and the use of the ASD to save files, instead of messing about with other file paths :wink:

The removal of the line returns in the base64String is not always necessary, but it helps....

Get me right Tim. I appreciated many things in the code. No doubt ! I just meant to point the KEY thing that saved my life. You're right it's not always necessary to remove the line returns as I didn't have to do it in another piece of code where I upload pictures.
Thx again.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.