tauri: [bug] Can not download in front end
Describe the bug
in the browser, we can use like this:
const eleLink = document.createElement("a");
eleLink.href = url;
eleLink.download = `${title} - ${artist}`;
eleLink.style.display = "none";
document.body.appendChild(eleLink);
eleLink.click();
document.body.removeChild(eleLink);
to download file in front; but in tauri,this function can not take effect.
Reproduction
No response
Expected behavior
No response
Platform and versions
› OS: Mac OS 12.4.0 X64
› Node.js: 16.14.0
› npm: 8.3.1
› pnpm: 6.32.3
› yarn: 1.22.17
› rustup: 1.24.3
› rustc: 1.61.0
› cargo: 1.61.0
› Rust toolchain: stable-aarch64-apple-darwin
Stack trace
No response
Additional context
No response
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 4
- Comments: 28 (11 by maintainers)
Temporary solution:
Don’t forget to enable dialogs.
Is there any plan for this being added to tauri still? It’s still not working in tauri 1.4 almost one year after it being fixed upstream (it was planned apparently to be added to tauri 1.3). It’s quite a critical issue for us.
On macOS nothing seems to happen at all. No errors in the console, no file is downloaded.
At least not to this locations:
~/It looks like this has been solved upstream. Has that made it into any releases for tauri? Are there any workarounds?
Is there any way to solve this part in the latest version of tauri? In my case, the download code is in the external domain, so I need a way to resolve it in the Tauri app if possible.
it still needs to be implemented in Tauri. wry#530 just made it possible to do so (by adding new apis). 530 by itself shouldn’t have added any behavior changes outside these new apis.
Thanks, it’s not throwing any errors anymore, just a few warnings:
On top of that, I also don’t know what to replace the
destinationwith, since I don’t have a default download path or anything like that. 🤔 Maybe I’ll stick with the workaround for now, as that also includes a save file dialogue.In main.rs or lib.rs depending on where you already have a
tauri::Builderline.yep. If you want to keep configuring the window in tauri.conf.json you can add
create: falseto the window config (requires latest tauri version) and then do something like thisI was in a situation where I couldn’t install the tauri module on the front-end, and I eventually handled it like this. Hope it helps someone.
@FabianLars Would be useful to know if this issue is likely to be fixed in the 2.0 release.