Add API for Base64.encode
/ Base64.decode
with an IO
as the source
#14603
Labels
Base64.encode
/ Base64.decode
with an IO
as the source
#14603
Related to #2964
Originally mentioned on the forum
In order to base64-encode data with
Base64.encode
, that data must exist in RAM. Technically, it just needs to be something that responds toto_slice
, but at least in the stdlib all of those things are actually stored in RAM:My use case is to base64-encode a file of arbitrary size. Some APIs accept JSON but allow you to send/receive file data inside that payload. I've had to do this a few times — for example, some email service providers allow you to send attachments embedded in JSON to their HTTP API, one integration I had to build for mortgage lenders to integrate with their loan origination system base64-encoded documents inside XML payloads, things like that.
In addition to certain email providers' specific APIs, you have to do the same in SMTP itself. SMTP is a text-based protocol, so attachments are typically encoded into a text-friendly format. The shard I typically use to send emails has to load the entire file into RAM.
So since base64-encoding nontrivial amounts of data is not an uncommon requirement, I figured this might be a good addition to the
Base64
stdlib.The text was updated successfully, but these errors were encountered: