Cross-platform, frontend-agnostic file picker and capability-based file access for Rust.
- Desktop (Windows, macOS, Linux, BSD) — via the
rfdcrate - Android — via the Storage Access Framework with persistable URI permissions
- iOS — via
UIDocumentPickerViewControllerwith security-scoped bookmarks - WASM — via
<input type="file">with in-memory file buffers
No UI framework dependencies. Returns standard Future values built on std primitives — usable from Dioxus, egui, Iced, pollster::block_on, or any other async or sync context.
[dependencies]
loki-file-access = "0.1.2"use loki_file_access::{FilePicker, PickOptions};
use std::io::Read;
let picker = FilePicker::new();
let token = picker
.pick_file_to_open(PickOptions {
mime_types: vec!["text/plain".into()],
..Default::default()
})
.await?;
if let Some(token) = token {
let mut reader = token.open_read()?;
let mut contents = String::new();
reader.read_to_string(&mut contents)?;
}On Linux, loki-file-access uses the XDG Desktop Portal (org.freedesktop.portal.FileChooser) for file dialogs, accessed via D-Bus.
Most desktop Linux environments (GNOME, KDE, etc.) provide this portal automatically. If the portal is not running, the file picker will silently return None — enable a tracing subscriber in your application to see the warning message that explains this.
When the XDG Desktop Portal is unavailable, loki-file-access automatically falls back to zenity if it is installed. Zenity is a GNOME utility that shows GTK file-chooser dialogs from the command line.
Install zenity on Debian/Ubuntu/ChromeOS Crostini:
sudo apt install zenityInstall on other distributions:
# Fedora
sudo dnf install zenity
# Arch
sudo pacman -S zenityIf zenity is also unavailable, a tracing::warn! is emitted and the picker
returns no selection.
The XDG Desktop Portal is not available inside the Crostini Linux container. Install zenity and the file picker will work via the zenity fallback:
sudo apt install zenityThe file picker does nothing on my Linux system.
-
Install zenity (the automatic fallback when the portal is unavailable):
sudo apt install zenity # Debian/Ubuntu/Crostini sudo dnf install zenity # Fedora sudo pacman -S zenity # Arch
-
If zenity is installed but the picker still does nothing, ensure the XDG Desktop Portal is present for your desktop environment:
# Debian/Ubuntu — GNOME sudo apt install xdg-desktop-portal xdg-desktop-portal-gtk -
Enable a
tracingsubscriber in your app (e.g.tracing_subscriber::fmt::init()) to see diagnostic messages from the picker. -
To explicitly disable the picker and surface a clear error instead of a silent no-op, set the environment variable:
LOKI_FILE_ACCESS_BACKEND=none ./your-app
Valid values:
auto(default),none.
MIT — see LICENSE.