Base64 Encode Function

It would be useful if we could send images and files as base64 encode strings in JSON payloads.

Status Not Planned
14 9 2,202
9 Comments
GreenFlux
Participant V

@Bellave_Jayaram, voted! I just spent the morning writing an Apps Script to this. It would be great if we could just have a function DECODE([Image])!

Here’s the script I came up with.

Bellave_Jayaram
Participant V

Thanks @GreenFlux!!

You are right, we can use your script approach but sometimes one needs to generate an encoded string on the fly and that is why I added the feature request.

Stefan_QREW
Participant V

This would be a very helpful feature for sending images to services outside of AppSheet. With the number of Image AI’s growing, I think this feature will only get more necessary in the future

FREDY_ORTEGON
Participant V

@Bellave_Jayaram Do you know any way that from appsheet I can encode a text string in “base64”?

Bellave_Jayaram
Participant V

No, hence the feature request. @Adam, can you shed any light here?

GreenFlux
Participant V

@Bellave_Jayaram, I know you’re looking for a method that avoids Apps Script, but what if the script is just to declare a custom function? Then you can apply the script via sheet formula, instead of having to invoke the script from AppSheet.

3X_e_4_e4a6da6164fd61a76fc224aef9b38641bcb3fafa.png

Apps Script

Summary

/**
 * Convert input string to Base64Encoded.
 *
 * @param {string} The input cell.
 * @return {string} The encoded string.
 * @customfunction
 */
function base64Encode(input) {
  if (input != ''){
  return Utilities.base64Encode(input.toString(), Utilities.Charset.UTF_8);
  }
  
}
/**
 * Convert base64Encoded input string to decoded string.
 *
 * @param {string} The input cell.
 * @return {string} The decoded string.
  * @customfunction
 */
function base64Decode(input) {
  if (input != ''){
  return Utilities.base64Decode(input, Utilities.Charset.UTF_8).toString();
  }
  
}

Bellave_Jayaram
Participant V

Thanks, yes that is a good option.

Status changed to: Open
Pratyusha
Community Manager
Community Manager
 
Status changed to: Not Planned
Roderick
Community Manager
Community Manager

I see how this could be helpful! Unfortunately, it's not currently in scope, but this could changed. We'll keep you posted if it does!