Link to file not working

Summary

Iโ€™m trying to link to a file in markdown and chrome blocks the hyperlink from working.

Steps to reproduce

Code snippet:

st.markdown('[Download me!](file://path/to/file/in/share)')

Expected behavior:

When I click the link, the file gets downloaded to my computer.

Actual behavior:

Nothing happens when I click the link. If I try to open it in a new tab, it redirects to about:blank#blocked.

Debug info

  • Streamlit version: 1.21.0
  • Python version: 3.9.10
  • OS version: Windows 10.0.19044 Enterprise
  • Browser version: Chrome 97.0.4692.99

Nevermindโ€ฆ This is a browser issue (sort of). You cannot open any link of the form file://..., itโ€™s a security feature. Iโ€™ll have to find a workaround.

An alternative could be st.download_button - Streamlit Docs.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.