npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

tauri-plugin-android-fs-api

v24.0.0

Published

Android file system API for Tauri.

Readme

Note: I’m using a translation tool, so there may be some inappropriate expressions.

Setup

First, install this plugin to your Tauri project:

src-tauri/Cargo.toml

[dependencies]
tauri-plugin-android-fs = { version = "24", features = ["legacy_storage_permission"] }

Next, register this plugin in your Tauri project:

src-tauri/src/lib.rs

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
    tauri::Builder::default()
        // Add following
        .plugin(tauri_plugin_android_fs::init())
        //
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

Then, set the APIs that can be called from the Javascript:

src-tauri/capabilities/*.json

{
    "permissions": [
        "android-fs:all-without-delete"
    ]
}

Finally, install the JavaScript Guest bindings using whichever JavaScript package manager you prefer:

pnpm add tauri-plugin-android-fs-api
# or
npm add tauri-plugin-android-fs-api
# or
yarn add tauri-plugin-android-fs-api

Usage

This plugin operates on files and directories via URIs rather than paths.

By using AndroidFs.getFsPath, you can obtain a path from a URI and use it with the functions provided by Tauri's file system, @tauri-apps/plugin-fs, to read and write files. For those paths, there is no need for you to set the scope configuration of Tauri's file system.

import { AndroidFs } from 'tauri-plugin-android-fs-api'
import { writeTextFile } from '@tauri-apps/plugin-fs';

/**
 * Save the text to '~/Download/MyApp/{fileName}'
 */
async function saveText(fileName: string, data: string): Promise<void> {
    const baseDir = "Download";
    const relativePath = "MyApp/" + fileName;
    const mimeType = "text/plain";

    const uri = await AndroidFs.createNewPublicFile(baseDir, relativePath, mimeType);

    try {
        const path = await AndroidFs.getFsPath(uri);
        await writeTextFile(path, data);
        await AndroidFs.scanPublicFile(uri);
    }
    catch (e) {
        await AndroidFs.removeFile(uri).catch(() => {});
        throw e;
    }
}

Some functions accept not only URIs but also absolute paths. In this case, you need to set the scope configuration in the same way as @tauri-apps/plugin-fs.

src-tauri/capabilities/*.json

{
    "permissions": [
        {
            "identifier": "android-fs:scope",
            "allow": [
                "$APPDATA/**/*"
            ],
            "deny": [
                "$APPDATA/secret.txt"
            ]
        }
    ]
}

And you can also assign a specific scope to a particular command.

src-tauri/capabilities/*.json

{
    "permissions": [
        {
            "identifier": "android-fs:allow-copy-file",
            "allow": [
                "$APPDATA/**/*"
            ],
            "deny": [
                "$APPDATA/secret.txt"
            ]
        }
    ]
}

Then, this plugin provides following APIs:

1. APIs to obtain entries such as files and directories.

  • AndroidFs.showOpenFilePicker
  • AndroidFs.showOpenDirPicker
  • AndroidFs.showSaveFilePicker
  • AndroidFs.readDir
  • AndroidFs.createNewFile
  • AndroidFs.createDirAll
  • AndroidFs.createNewPublicFile
  • AndroidFs.createNewPublicImageFile
  • AndroidFs.createNewPublicVideoFile
  • AndroidFs.createNewPublicAudioFile

3. APIs to retrieve data from entries.

  • AndroidFs.getThumbnail
  • AndroidFs.getThumbnailBase64
  • AndroidFs.getThumbnailDataUrl
  • AndroidFs.getFsPath
  • AndroidFs.getName
  • AndroidFs.getByteLength
  • AndroidFs.getType
  • AndroidFs.getMimeType
  • AndroidFs.getMetadata

3. APIs to operate entries.

  • AndroidFs.scanPublicFile
  • AndroidFs.copyFile
  • AndroidFs.truncateFile
  • AndroidFs.removeFile
  • AndroidFs.removeEmptyDir
  • AndroidFs.removeDirAll

4. APIs to manage entry permissions

  • AndroidFs.persistUriPermission
  • AndroidFs.checkPersistedUriPermission
  • AndroidFs.releasePersistedUriPermission
  • AndroidFs.releaseAllPersistedUriPermissions
  • AndoridFs.hasPublicFilesPermission
  • AndroidFs.requestPublicFilesPermission

5. APIs to send entries to other apps.

  • AndroidFs.showViewFileDialog
  • AndroidFs.showViewDirDialog
  • AndroidFs.showShareFileDialog

6. Helper

  • isAndroid

For simplicity, some features and detailed options of the API have been omitted. If you need them, please consider using the tauri-plugin-android-fs on the Rust side.

License

This project is licensed under either of

  • MIT license
  • Apache License (Version 2.0)

at your option.