Pass a BLOB

129 views
Skip to first unread message

Michael O'Shaughnessy

unread,
May 22, 2022, 8:44:44 PM5/22/22
to Google Apps Script Community
(TL;DR - How do you pass a JSON BLOB as an argument in google.script.run?)
Hello experts!! 
I am running into an issue of needing to pass a BLOB formatted as JSON from a Web App to another Web App acting as an API to save the data to a spreadsheet.

I am using Tabulator (http://tabulator.info/) because so far it is fitting my needs of loading a table with data from a Google Sheet, allowing it to be edited, and then "downloaded" as JSON.  What I want to do is to "intercept" the download and send the JSON file to be processed by another Web App.

Tabulator can do this (http://tabulator.info/docs/5.2/callbacks#download) and the download is the JSON data that I want. 

What I cannot find out how to do is to get the JSON BLOB created by Tabulator sent to a server side script using google.script.run.

I can provide code that I have HOWEVER what I am pretty sure is I just need help passing a BLOB using script.run

I have researched and have found it cannot be done and what needs to be done is encode the BLOB using Base64... and that is where I am lost.

So, nutshell:
How to encode a BLOB in Base64, pass it as an argument using script.run then decode it to be used?

Thanks in advance for guidance and suggestions!!

Jonathan Butler

unread,
May 23, 2022, 1:00:31 PM5/23/22
to google-apps-sc...@googlegroups.com
I believe you can use btoa to encode a blob to base 64 client side. To get the binary array you can choose one of the options here. The file reader is probably the most simple.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/2181b759-e4fc-4402-a9ba-00354912f826n%40googlegroups.com.

Tanaike

unread,
May 23, 2022, 11:08:40 PM5/23/22
to Google Apps Script Community
For this situation, I prepared a simple sample script. Is that useful for your situation? If that was not useful, I apologize.

https://tanaikech.github.io/2022/05/24/exporting-tabulator-data-to-google-drive-using-google-apps-script/

Michael O'Shaughnessy

unread,
May 24, 2022, 9:30:21 PM5/24/22
to google-apps-sc...@googlegroups.com
Success!  I found this on Stackoverflow

I was able to adapt it to work for me.

It is the small victories that make coding so rewarding!!!

Now, back to my project!

--
Reply all
Reply to author
Forward
0 new messages