Docly Developers
Function Updated 17 Oct 2026

downloadFromUrl64(mimeType, url)

Downloads a file from the specified URL and returns it as a base64 data URL (data:<mimeType>;base64,...), ready to use in an img src or a CSS url(). Only http:// and https:// URLs are allowed. The request goes through the same outbound guard as httpFetch: Docly controller domains and link-local/cloud-metadata addresses are blocked. Throws if the download fails or the server answers with an error status.

Parameters

mimeTypestringrequired

MIME type written into the data URL, e.g. "image/png". It is not detected from the response — pass the type of the file you download.

urlstringrequired

URL to download with HTTP GET (http:// or https://).

Returns

Returns the downloaded bytes as a data URL: "data:" + mimeType + ";base64," + base64 content. Returns null unless exactly two arguments are given.

Example

Mixed HTML (or any text file) with inline JavaScript between hash signs.
#{
    var src = docly.downloadFromUrl64("image/png", "https://example.com/image.png");
}#
<img src="#src#" alt="Example" />