Discover all of the brand-new features and improvements to existing capabilities in the Dataiku 11.3 updateLET'S GO

Using imge files in Dash App

Usersyed
Level 3
Using imge files in Dash App

Hi all,

I have an image file placed under the static web resources in Dataiku.
How do we specify the path for this image so that I can use this image in my Dash app?

Note: I am using an online instance of Dataiku and not on my local server.


Operating system used: Windows

0 Kudos
2 Replies
AlexT
Dataiker

Hi @Usersyed ,

Global Shared Code is not available on Dataiku Online instances at this time. So you will not be able to use static resources. You should instead use a Managed folder where you store the images and read from that folder. 

import plotly.express as px
import dataiku
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
import plotly.graph_objects as go
import dash
import base64

#replace images with the actual folder name
folder = dataiku.Folder("images")

with folder.get_download_stream("subfolder/test.png") as stream:
    encoded_image = base64.b64encode(stream.read())
    #print(encoded_image)

    app.layout = html.Div([
       html.Img(src='data:image/png;base64,{}'.format(encoded_image.decode()))
       
    ])



0 Kudos
Usersyed
Level 3
Author

@AlexT Thank you for this solution.
I will test this one also.
I tried using "/local/static/image_name"  as the file path and it worked.

0 Kudos