Cross Platform File Selection API
Feature Request
Dioxus should have a cross platform api for programmatic file selection/saving.
Currently, we can use
rsx! {
input { r#type: "file" }
}
for file selection on web and desktop, and once https://github.com/DioxusLabs/dioxus/issues/3849 is resolved, mobile as well. Thus giving us a cross platform file selection element.
But there is no direct file selection api that can be invoked programmatically. On desktop we can use rfd directly with e.g. rfd::FileDialog::new().set_directory(&path).pick_file();, but this does not work for web or mobile. Thus there should be an api that can be used directly that covers web, desktop, and eventually mobile.
On web, the set_directory option should be ignored, since browsers are sandboxed so it will not have an effect.
Kevinaboss: Also, we have a fork of the directories crate that supports Android, so you can use the local dir meant for app data, caching, config/settings data, etc https://github.com/project-robius/robius-directories
The above message was on our discord mobile channel. Maybe underneath we can utilize this somehow. Just posted message here thinking it might be helpful when developing something for this issue.
That may become useful if we added an api like dioxus::FileDialog::new().pick_app_data_file(). More likely keeping it separate in something like dioxus::FileDialog::new().set_directory(dioxus::directories::app_data()).pick_file() may be more flexible. If robius-directories does not end up maturing or supporting IOS, I definitely think it would be worthwhile for dioxus to implement/maintain a cross platform "path provider" since there doesn't seem to be one. It's a shame all dirs-dev projects were recently archived.
Also in the prior art in that vein, it is worth noting that flutter maintains its own "path provider" and has implementations for all the platforms for common paths https://github.com/flutter/packages/tree/main/packages/path_provider/path_provider But it uses native code and is bridged to dart.