Solved

File Download from Front Plugin

  • 19 March 2024
  • 1 reply
  • 119 views

Hi all!

We’ve built a sidebar plugin that serves up relevant information to our users about the email that they’re viewing.

One of the things we’d like to do is allow them to download documents related to the email.

We have an API that we’re reaching out to that returns the file in base-64. We’ve been unable to serve the file up to the user to download as the iframe the plugin is in doesn’t allow popups or downloads.

We’ve considered temporarily saving the file to blob storage and then using the openUrl function to access it but that seems like an expensive solution.

Any insight would be appreciated!

icon

Best answer by evano 20 March 2024, 19:07

View original

1 reply

Userlevel 2
Badge +5

Hi sbeitel,

Currently, Front plugins can't allow downloads from the sandboxed iframe.  To my knowledge, there are no existing product plans to change this.  You can suggest product improvements through our Ideas Portal:

https://community.front.com/ideas

In the meantime, you can implement a workaround by using the plugin SDK method openUrl to open a link in an external browser window.  If your server's HTTP response for that link includes Content-Disposition: attachment; an automatic download will be started:

https://stackoverflow.com/questions/9195304/how-to-use-content-disposition-for-force-a-file-to-download-to-the-hard-drive

Reply