PolyMeilex / rfd

Rusty File Dialog
MIT License
538 stars 59 forks source link

AsyncFileDialog in web context show some kind of progress bar ? #204

Open fmartinsons opened 3 weeks ago

fmartinsons commented 3 weeks ago

Hello,

I'm using egui for building a web app and I use rfd to offer the user to pick a file. Some of file candidate can be big and/or hosted on a low bandwith network drive so when I do something like:

let task = rfd::AsyncFileDialog::new()
    .set_title("Choose a file please")
    .pick_file();
wasm_bindgen_futures::spawn_local(async move {
    let file = task.await;
    if let Some(file) = file {
        let contents = file.read().await;
    }
});

The call to file.read() can take several dozen of seconds (even more) , in the UI, I'm currently showing a spinner saying "loading in progress" but I would like to display some kind of progress bar showing the percentage of file downloaded.

I see rfd used web_sys FileReader and this class seems to have some kind of "progress" support with set_onprogress.

I must admit that I know very little in the web/js world so it may be a silly question but do you think it is something achievable ?

Thanks