Download big zipfile

Hi!!.
im would like to download big zipfiles in my dash app, i’ve tried background callbacks, but still dont work.
it seems that its only able to download 50 Mb maximum…

Hey @jpaton, is your app deployed locally?

This works locally for me:

import dash
from dash import html, dcc, Input, Output
import numpy as np

app = dash.Dash(__name__)

app.layout = html.Div(
    [
        html.Button(
            'click',
            id='btn'
        ),
        dcc.Download(id='down'),
        dcc.Loading(
            html.Div(id='out')
        )
    ]
)


@app.callback(
    Output('down', 'data'),
    Output('out', 'children'),
    Input('btn', 'n_clicks'),
    prevent_initial_call=True
)
def save_file(_):

    # crete dummy data (size is approx. 800MB)
    a = np.random.randint(0, 255, size=(1000, 1000, 100))

    # send array as bytes
    return dcc.send_bytes(a.tobytes(), 'numpy.bytes'), 'Download finished'

    # send a file from HDD
    # return dcc.send_file(path='./numpy.bytes', filename='sent_file.bytes'), 'Download finished'


if __name__ == "__main__":
    app.run(debug=True)

nope, works remote.

Since this works locally, you’ll have to add some information on how exactly is your setup- I guess.

Hello @jpaton,

It looks like you might be running into an issue with the timeout, this would be better handled in Flask vs Dash, as Flask can generate responses in chunks, therefore you arent waiting for the whole thing to process and download:

You could generate a clientside callback to send the request to the flask server.

1 Like