Display image in Databricks notebook error

Viewed 2859

I am working on creating a databricks notebook template with company logo. Using the below code to display image is throwing error.

Code:

%md
<img src ='/test/image/MyImage.jpg'>

Error:

HTTP ERROR 403: Invalid or missing CSRF token

Please guide me.

1 Answers

You either need to store image somewhere, and refer to it as a full URL, for example, you can refer your company site.

Another way is to upload file to the /FileStore directory on DBFS, and then you can refer to it using the /files/ URL, that is supported in both HTML and Markdown (see docs):

%md
![my_test_image](files/image.jpg)

You can upload image using databricks-cli, or via UI (if you have DBFS File Browser enabled). (Another option is the DBFS REST API, but it's cumbersome)

Related