My app is hosted on AWS and I want the user to download a pre-generated seaborn heatmap available in a folder (viewable by the app but not necessarily in the same directory).
Here is my code:
html.Div(children=[html.A(id='heatmap_url')]),
and the callback whiich updares this:
@app.callback([Output('heatmap_url', 'href'),
Output('heatmap_url', 'download'),
Output('heatmap_url', 'children'),
Output('heatmap_url', 'style')],
[Input('stored-url','children')])
def get_download_link(output_msg, heatmap_link):
heatmap_link, heatmap_file, heatmap_text = '', '', ''
style = {'width':'150px', 'text-align':'center', 'padding':'0px', 'display':'none'}
if stored_url != '':
heatmap_link = session_variables[stored_url]['heatmap_url']
heatmap_file = heatmap_link.split('/')[-1]
heatmap_text = 'Download: %s' % heatmap_link
style = {'width':'150px', 'text-align':'center', 'padding':'0px'}
return heatmap_link, heatmap_file, heatmap_text, style
context: In another callback I check if the file exists. If not, the output for 'stored_url', 'children'
becomes ''
.
stored__url
is something like: /D/user/home/documents/heatmap_name.png
I can get the browser to download a png with the correct name, but when I open the file it says: heatmap_name.png It looks like we don't support this file format.
in my native Windows 10 Photos app. I tried opening it in Paint, uploading it to Google Drive, nothing worked.
How can I get the user to view the image? I was originally using html.Img
but the images are too big for my app.
Can I perhaps get the user to open the PNG in a new window by clicking the link?