Skip to content

support dcc.send_file and dcc.send_data_frame #112

Closed

Description

@kafisatz

This is a cross post from https://discourse.julialang.org/t/dash-jl-send-file-or-send-data-frame/63499

Is it correct, that dcc.send_data_frame and dcc.send_file are not supported yet.
I am trying to reproduce these examples in Julia
https://dash.plotly.com/dash-core-components/download

dcc.send_file seems most critical to me.

Activity

  1. kafisatz commented on Jul 1, 2021

    @kafisatz
    Author

    turns out that for a DataFrame -> csv file, there is quite a simple workaround

    callback!(app,
                Output("download-modelresult","data"),            
                Input("btn-download-model-results", "n_clicks"),
                prevent_initial_call = true
            ) do n_clicks
        
        df = DataFrames.DataFrame(a=rand(3),b=["a","b","xx"])
        csvrowwriteriterator = CSV.RowWriter(df)
        str = join(collect(csvrowwriteriterator))
        return Dict("filename"=>"miha.csv","content"=>str ,"base64"=>false)
    
    end 
    
  2. kafisatz commented on Jul 1, 2021

    @kafisatz
    Author

    similarly for any file on disk, this works for me

    #send file from disk 
                file_from_disk = raw"c:\temp\temp.7z"
                #file_from_disk = raw"c:\temp\png1.png"
                rf = read(file_from_disk)
                io = IOBuffer()
                iob64_encode = Base64.Base64EncodePipe(io)
                write(iob64_encode,rf)
                close(iob64_encode)
                str = String(take!(io))
                #String(Base64.base64decode(str))
                fn = splitdir(file_from_disk)[2]
                return Dict("filename"=>fn,"content"=>str,"base64"=>true)
    
  3. linked a pull request that will close this issueHelper functions #144on Nov 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions