JavaScript Bridge
Downloading Files from JavaScript
Send an explicit authenticated download request to the native in-app downloader.
Before you start
- File Downloader enabled
- A downloadable URL or data source
Configure and verify
Prepare the URL
Use a short-lived HTTPS URL when possible.
Add optional metadata
Pass filename, MIME type, referrer, and short-lived request headers in the options object.
Start the download
Call webtoapp.downloadFile(url, options) from a user action.
Let native UI report progress
The configured panel shows status and completion actions. Test cancellation and opening the saved file.
Example
webtoapp.downloadFile(reportUrl, {
filename: "annual-report.pdf",
mimeType: "application/pdf",
headers: { Authorization: "Bearer " + shortLivedToken }
});Security
Test before release
- URL uses HTTPS
- Token expires quickly
- Filename and MIME type are correct
- Cancel and open were tested