wave
wave copied to clipboard
Links don't download when button is True
Wave SDK Version, OS
Wave 0.17.0 safari & chrome
Actual behavior
When using ui.link(download=True, button=True)
the file opens in a new tab but is not actually downloaded locally. When button=False
the file downloads as expected
Expected behavior
File to download
Citing docs on download
attribute:
True if the link should prompt the user to save the linked URL instead of navigating to it. Works only if button() is false.
Would love to know why this is a functionality? A download button seems like a common UI element.
@mturoci A button with a download attribute would be useful.
Agree, just wasn't sure if there isn't any non-obvious reason for this from your side @lo5. The implementation should be a no-brainer, will do.
@mtanco can you please put up a small repro?
I managed to download with a button link like so:
ui.link(
label='Download link',
path='https://file-examples-com.github.io/uploads/2017/02/file-sample_100kB.doc',
download=True,
button=True
)
@mturoci it doesn't work for me
@Daniel-Kelvich can you add a min repro code please? Thanks!
@mturoci sure
from h2o_wave import main, app, Q, ui
@app('/downloads')
async def serve(q: Q):
download_path, = await q.site.upload(['data/img.png'])
q.page['download'] = ui.form_card(box='1 1 2 2', items = [
ui.link(label='Download Results', path=download_path, download=True, button=True),
])
await q.page.save()
The current state of download
attr is:
- If the resource can be opened by the browser itself (jpg/pdf etc.), open it in browser.
- If the resource cannot be opened by the browser (.docx etc.), download it.
The reason was bug in Firefox that dropped websocket connection when clicking the link with download
attribute. It may be fixed in newer versions though so worth revisiting for sure.
Is there a way to force a download irrespective of format? Or at least open in a new tab?
Was facing a similar issue while using .json
files.
Particularly because when the file is opened in browser, there is no way to go back to the app without refreshing it (losing saved arguments in the process).
cc: @Nischaydnk
Or at least open in a new tab?
Yes, this should be possible via target
attribute.
It seems like I managed to get the download work consistently across browsers. Should be possible in the next release.
My use-case is a download through meta's redirect
: https://github.com/vopani/waveton/blob/main/apps/data_apps/image_annotation/app.py#L284
Download through meta's redirect is more of a hack than a real solution as it should be used for redirects.
I think we should provide a native way of forcing the download programmatically, something like meta.download. Could you please file a separate feature request? This one deals with downloads after the user clicked.