How to programmatically generate download link?

I am curious if anything else came from this. We are having a bunch of users migrating from Classic to Lab and this is biting us really hard, but even in recent versions of Classic it is sending them to HTML pages rather than the raw file, even for something like a .tar.gz.

The ONLY way we have gotten this to work in Lab is to ignore FileLink all together and build html for the link manually add the download attribute display(HTML(“foo”)).

Jupyter Classic, I haven’t found a way around this because display(HTML(“foo”)) and display(FileLink(‘foo.txt’)) in Classic is generating /notebooks/foo.txt but in lab generating /files/foo.txt. The former is an HTML page for editing the the file, while the latter, missing a “download” attribute, is intercepted by Jupyterlab and it opens the file in another tab.