0

I created a web service that returns the base64 of charts. I need to get it and show it inside of a card in hangout chatbot. But the only whay that I found was save in google drive.

There is a way to do that without save the file?

Javascript code:

function getbase64(base64){ //Function that I used to save in Google Drive

   currentFolder = DriveApp.getFolderById("id-folder");
   blob = Utilities.newBlob(Utilities.base64Decode(base64),'image/png').setName("teste.png")
   currentFolder.createFile(blob);

}

function card(x){ //Function that returns a card
   return {
      "cards": [{
       "sections": [{
        "widgets": [ {
         "image": { "imageUrl":x}},{
          "buttons": [{
           "textButton": {
            "text": "Open Image",
             "onClick": {
               "openLink": {
                 "url": x}}}}]}]}]}]}}


function onMessage(e) { //Function that I used to try show base64 in a card without save in google drive
   if(e.message.text == 'chart') {
      var base64data = 'data:image/jpg;base64,iVBORw0KGgoAAAANSUhEUgAAAlgAAAOECAYAAA=='
      return card(base64data)
   }

}
  • Can you share the code you use to insert the image into the card? It might be possible with [Array Buffers](https://stackoverflow.com/questions/35038884/download-file-from-bytes-in-javascript) – Jescanellas Jul 04 '19 at 14:36
  • @Jescanellas I edit my post... I used functions card and onMessage. I'll take a look in your link! Thank you – joaoflauzino Jul 04 '19 at 16:38

0 Answers0