- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2021 02:31 PM
I am creating plots in databricks using python and matplotlib. These look great in notebook and I can save them to the dbfs using
plt.savefig("/dbfs/FileStore/tables/[plot_name].png")
I can then download the png files to my computer individually by pasting a url in my browser like
https://[address]/files/tables/[plot_name].png
What I'm wondering is if there is a way to run this url and download the png file for a plot programmatically when I run a notebook
- Labels:
-
DBFS
-
Matplotlib
-
Python
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2021 12:27 AM
Hello Hunter,
I think that you pushed it too far - FileStore download via web browser is a cool feature, when you want to download file to your local in the quickest possible way.
Do you have an external storage mounted to you workspace? Storages like Azure Storage, S3 has their own APIs, multiple SDKs and you should be heading that direction to download it programatically.
Hope it helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2021 09:50 AM
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2021 02:00 PM
Hi Hunter,
FileStore is a special folder within Databricks File System (DBFS) where you can save files and have them accessible to your web browser. In your case it the png files will be saved into /FileStore/plots which contains images created in notebooks when you call display() on a Python or R plot object, such as a ggplot or matplotlib plot. If you delete files in this folder, you may have to regenerate those plots in the notebooks that reference them.
If you would like to download the files, then you will need to follow the instructions from here to create the url https://docs.databricks.com/data/filestore.html#save-a-file-to-filestore
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2021 12:27 AM
Hello Hunter,
I think that you pushed it too far - FileStore download via web browser is a cool feature, when you want to download file to your local in the quickest possible way.
Do you have an external storage mounted to you workspace? Storages like Azure Storage, S3 has their own APIs, multiple SDKs and you should be heading that direction to download it programatically.
Hope it helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2021 01:40 PM
Hi Hunder, Please find the below steps to download the png file
- Copy the png file to a file store location Eg. - dbfs:/FileStore/tables/DeltaLakeCheatSheet.png
- In a separate browser tab, I entered the below URL to automatically download the file to the local.
https://<mycompany.databricks.com>/files/tables/DeltaLakeCheatSheet.png?o=######
a. Replace <mycompany.databricks.com> with the URL you have used to login to databricks
b. ?o=######" where the number after o= is the same as in your URL
Also, the below example, which displays a hyperlink to the png file which can be used to download the png file
displayHTML("""
<p> This is a link <a href="files/tables/DeltaLakeCheatSheet.png?o=######"> link</a> to the document </p>
""")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2021 08:23 AM
Thanks for the html trick Shan_Chandra, I'll use that in my reports.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2021 08:19 AM
Thanks everyone! I am already at a place where I can download a png to FileStore and use a url to download that file locally. What I was wondering was if there is some databricks function I can use to launch the url that references the png file and download it. But it sounds like that may not be possible currently.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2022 01:53 PM
Hi Hunter,
Did you ever find a way to automatically download? I tried going the route of running a jupyter instance on my local laptop and using the requests package to hit the Databricks Filestore url, but I am getting an error. Wondering if you ended up solving this.
Cheers
Peter

