Skip to content

AppThere/loki-file-access

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

loki-file-access

Cross-platform, frontend-agnostic file picker and capability-based file access for Rust.

Features

  • Desktop (Windows, macOS, Linux, BSD) — via the rfd crate
  • Android — via the Storage Access Framework with persistable URI permissions
  • iOS — via UIDocumentPickerViewController with 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.

Quick start

[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)?;
}

Linux requirements

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.

Zenity fallback

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 zenity

Install on other distributions:

# Fedora
sudo dnf install zenity

# Arch
sudo pacman -S zenity

If zenity is also unavailable, a tracing::warn! is emitted and the picker returns no selection.

ChromeOS Crostini

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 zenity

Troubleshooting

The file picker does nothing on my Linux system.

  1. 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
  2. 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
  3. Enable a tracing subscriber in your app (e.g. tracing_subscriber::fmt::init()) to see diagnostic messages from the picker.

  4. 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.

License

MIT — see LICENSE.

About

Cross-platform, frontend-agnostic file picker and capability-based file access for Rust

Topics

Resources

License

Stars

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors