asset2base64 - Convert Asset into Base64 String
Converts an uploaded asset (image, zip, audio, video, pdf, ...) or loads and converts the asset from the given URL to a base64 string.
This function can be useful for embedding assets into emails or other applications that require base64-encoded files. Here are some examples of how this function can be used:
- Converting an image file to a base64 string and embedding it into an email.
- Converting a PDF file to a base64 string and sending it to a server for processing.
- Converting an audio file to a base64 string and embedding it into a web page.
url
string
The URL of the asset to be converted into a base64 string.
Example:
https://api.1001fx.com/testdata/image.png
addPrefix
boolean
Specifies if the prefix 'data:MimeType;base64,' should be added to the result string. Default is true.
Example:
file
binary
Asset file to be processed.