Hi,
I am new to Dash. I am creating an application where I need to download large files. I tried using dcc.Download
. This components works well with small size files (upto ~300 MB). However, when I try to download large files (around ~ 500 MB) this component never downloads the file. As a check I also tried adding a dcc.Loading
component to check if download is complete (dcc.Loading
will change its message when download completes). For large files text of dcc.Loading
also never gets updated. Would appreciate any help with this issue.
Following is the code I used:
import io
from os import close
import dash
from dash.dependencies import Output, Input
import dash_html_components as html
import dash_core_components as dcc
import matplotlib.pyplot as plt
import zipfile
from io import BytesIO
app = dash.Dash(prevent_initial_callbacks=True)
app.layout = html.Div([html.Button("Download zip", id="btn_txt"),
dcc.Loading(
id="loading-control",
type="default",
fullscreen=False,
children=[
html.Div("Requesting file", id="loading-child"),
]
),
dcc.Download(id="download-zip")]
)
@app.callback(
[
Output("download-zip", "data"),
Output("loading-control", "children")
],
Input("btn_txt", "n_clicks"),
prevent_initial_call=True,
)
def func(n_clicks):
file_path = "C:\\LargeFile.zip"
return dcc.send_file(file_path, "Large File.zip"), ["File downloaded"]
if __name__ == "__main__":
app.run_server(debug=False)
Thanks in advance.