Submit your inspiring success story or innovative use case to the 2022 Dataiku Frontrunner Awards! ENTER YOUR SUBMISSION

Using static files in WebApps without being an Administrator

Anker
Level 1
Using static files in WebApps without being an Administrator

I want to use a statis file (let's say, an image) in the Dash app. Browsing the internet I learned that for that I have to go to Global Shared Code (which is insane, cause I don't want to make this image global and I would rather keep it inside the project) and upload it there.

However, this is not an option for me, because I don't have admin rights on this DSS instance. How someone, who is not an administrator, could upload and use the static image (or any other file) in the WebApp or in the recipe? 

0 Kudos
1 Reply
pmasiphelps
Dataiker
Dataiker

Hi Anker,

You can create a managed folder in your project flow, then drop the image into it:

Screen_Shot_2022-02-02_at_10_21_47_AM.png

 In your dash app, you can read in the image file from the folder like this:

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

folder = dataiku.Folder("INSERT_FOLDER_NAME")

with folder.get_download_stream("IMAGE_FILE_NAME.jpg") as stream:
    encoded_image = base64.b64encode(stream.read())

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

Best,

Pat

 

 

0 Kudos