DownloadBytes(data, filename, [preview]) Last updated: 14. Nov 2024

API only function

A method to trigger a file download from byte data or a base64 encoded string.

Parameters

Name Type Description
data base64 | byte[] The file data to be downloaded, which can be in base64 format or a byte array.
filename string Filename to download.
preview (optional) bool Default false, returns a preview and not a download. Meaning it will show / preview in the browser.

Returns

Starts a file download immediately in the API call and aborts further execution of code in the script.

Example

Code example (JS)

JS is normal JavaScript either running in the browser or on the Docly™ server.
// Generate a PDF download for a specific Docly document
let data = [1,2,4,43,54,4];

docly.downloadbytes(data, 'example.pdf', false);