I found this blog post
article on Base64 encoding on Arduino.
Here is the relevant block of code from the article
size_t size = image.size;
const uint8_t* image = image.data;
uint8_t *buffer = calloc((size + 2 - ((size + 2) % 3)) / 3 * 4 + 1, sizeof(char));
size_t buff_size = 0;
int err = mbedtls_base64_encode(buffer, (size + 2 - ((size + 2) % 3)) / 3 * 4 + 1,
&buff_size, image, size);
if (err != 0) {
ESP_LOGE(TAG, "error base64 encoding, error %d, buff size: %d", err, buff_size);
return; <pre lang="text">
}