Using static files in WebApps without being an Administrator

Options
Anker
Anker Dataiku DSS Core Designer, Registered Posts: 1 ✭✭✭

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?

Answers

  • pmasiphelps
    pmasiphelps Dataiker, Dataiku DSS Core Designer, Registered Posts: 33 Dataiker
    edited July 17
    Options

    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

Setup Info
    Tags
      Help me…