Download File

Download File at Specified URL

Run the following Median JavaScript Bridge command to initiate the download of the file at the specified URL.

↔️Median JavaScript Bridge

To download a file:

median.share.downloadFile({url: 'https://yoursite.com/file.pdf', open: true|false})
// Note: 'open' is an Android-only parameter, refer to below

On iOS, the file is downloaded and passed to the "open with" system dialog.

On Android, if Downloads Folder is set on the Permissions tab, by default the file will be downloaded silently. If the open: true parameter is set once the download is complete an "open with" dialog will be displayed.

On Android, if Private to App is set on the Permissions tab, the file will be downloaded internally and your app will always display an "open with" dialog.

Save Image to Photos

↔️Median JavaScript Bridge

To download an image to the user's iOS photo library / Android photo gallery:

median.share.downloadImage({url: 'https://yoursite.com/file.jpg'})

👍

Developer Demo

Display our demo page in your app to test during development https://median.dev/download-functions/

Viewing PDF files in the app

You can view the PDF files directly in the app using a few different methods

// Navigate to the PDF file's url
window.location.href = 'https://yoursite.com/file.pdf'
// Use the downloadFile function
median.share.downloadFile({url: 'https://yoursite.com/file.pdf', open: true})

For iOS, we utilize the built-in PDFKit framework provided by Apple.
For Android we are using the PDFViewer library https://github.com/afreakyelf/Pdf-Viewer

iOS Android

👍

Developer Demo

You can see the PDF viewer in action on our demo page https://median.dev/pdf-download/


Next Steps