# How to add download pptx from link

**URL:** <https://community.plotly.com/t/how-to-add-download-pptx-from-link/45188>\
**Category:** Dash Python\
**Created:** [September 22, 2020, 12:11pm UTC](https://community.plotly.com/t/how-to-add-download-pptx-from-link/45188 "2020-09-22T12:11:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhinav](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@Abhinav](https://community.plotly.com/u/Abhinav)\
**Post date:** [September 22, 2020, 12:11pm UTC](https://community.plotly.com/t/how-to-add-download-pptx-from-link/45188/1 "2020-09-22T12:11:19Z")

</div>

Hi All,

I am adding click functionality to download pptx file from given link but every time it is creating a blank pptx file below is sample code:

```auto
import dash
import dash_core_components as dcc
import dash_html_components as html
import dash_bootstrap_components as dbc
from dash.exceptions import PreventUpdate
from dash.dependencies import Input, Output
from os import path
from flask import send_file
from pptx import Presentation
import io

app = dash.Dash( __name__ ,external_stylesheets=[dbc.themes.BOOTSTRAP])

app.layout = html.Div([html.Div([html.A("Download PPT",href="/download_ppt/")],id = 'excel')])

#download cluster report
@app.server.route("/download_ppt/")
def download_excel():
    if path.exists("insights.pptx"):
        # Create DF
        f=open('insights.pptx','rb')
        prs=Presentation(f)
        f.close()
        #filename = io.BytesIO()
        filename = io.StringIO()         
        prs.save(filename)
        filename.seek(0)
        return send_file(
            filename,
            mimetype = 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 
            attachment_filename="download.pptx",
            as_attachment=True,
        )
    else:
        raise PreventUpdate

if __name__ == " __main__":
    app.run_server()

```

---

<div class="post-metadata">

**Author:** ![Emil](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/emil/32/31734_2.png) [@Emil](https://community.plotly.com/u/Emil)\
**Post date:** [September 22, 2020, 1:02pm UTC](https://community.plotly.com/t/how-to-add-download-pptx-from-link/45188/2 "2020-09-22T13:02:15Z")

</div>

Have you tried the `Download` component from dash\_extensions? Here is a small example demonstrating how to download files.

```auto
import dash
import dash_html_components as html  
from dash.dependencies import Output, Input
from dash_extensions import Download
from dash_extensions.snippets import send_file

app = dash.Dash(prevent_initial_callbacks=True)
app.layout = html.Div([html.Button("Download", id="btn"), Download(id="download")])

@app.callback(Output("download", "data"), [Input("btn", "n_clicks")])
def func(n_clicks):
    return send_file("/home/emher/Documents/Untitled.png")

if __name__ == ' __main__':
    app.run_server()

```

---

<div class="post-metadata">

**Author:** ![Abhinav](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@Abhinav](https://community.plotly.com/u/Abhinav)\
**Post date:** [September 22, 2020, 2:25pm UTC](https://community.plotly.com/t/how-to-add-download-pptx-from-link/45188/3 "2020-09-22T14:25:01Z")

</div>

> [@Emil](#):
>
> ```auto
> import dash
> import dash_html_components as html  
> from dash.dependencies import Output, Input
> from dash_extensions import Download
> from dash_extensions.snippets import send_file
> 
> app = dash.Dash(prevent_initial_callbacks=True)
> app.layout = html.Div([html.Button("Download", id="btn"), Download(id="download")])
> 
> @app.callback(Output("download", "data"), [Input("btn", "n_clicks")])
> def func(n_clicks):
> return send_file("/home/emher/Documents/Untitled.png")
> 
> if __name__ == ' __main__':
> app.run_server()
> 
> ```

Thanks it is working!! Thanks for creating this extension and make our life easy.
