fyne-io / fyne

Cross platform GUI toolkit in Go inspired by Material Design
https://fyne.io/
Other
25.1k stars 1.4k forks source link

Handle file saving dialog as a file download in the web driver #2738

Open Bluebugs opened 2 years ago

Bluebugs commented 2 years ago

Is your feature request related to a problem? Please describe:

The web doesn't come with a file save dialog feature. You are expected to download a file. It would be nice to have that capability working seamlessly as if it was a on the desktop.

Is it possible to construct a solution with the existing API?

Ideally no new API should be added.

Describe the solution you'd like to see:

No idea yet.

Bluebugs commented 2 years ago

This link point to some easy to implement solution to locally generate a file and save it: https://stackoverflow.com/questions/52683706/how-can-one-generate-and-save-a-file-client-side-using-blazor

Bluebugs commented 2 years ago

Current idea would be to not have a dialog implemented per see for saving, but it will return in memory file which will trigger a []byte -> base64 -> download link on the URI being closed. This would lead to the file being saved locally by the browser.

Bluebugs commented 2 years ago

Maybe slight intermediate step would be to propose typing a file name before returning the uri.

andydotxyz commented 2 years ago

Maybe slight intermediate step would be to propose typing a file name before returning the uri.

I guess not all browsers offer the user get a chance to set the filename when the download dialog opens... The default can be set in the file dialog API but a reasonable fallback does need to be provided.

Bluebugs commented 2 years ago

At least for the browser I use, Firefox, Chrome and Edge, there is no dialog to choose the file to save in. The file is named by the website and downloaded straight into Downloads/.