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 🙏

© 2026 – Pkg Stats / Ryan Hefner

tauri-plugin-android-fs-api

v27.1.0

Published

Android file system API for Tauri.

Readme

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

Overview

This plugin provides a unified file system API for all Android versions supported by Tauri.

Setup

First, install this plugin to your Tauri project:

src-tauri/Cargo.toml

[dependencies]
tauri-plugin-android-fs = { version = "=27.1.0", features = [
    # For `AndroidFs.createNewPublicFile` and related APIs on Android 9 or lower
    "legacy_storage_permission",
    # For notification options
    "notification_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()
        .plugin(tauri_plugin_android_fs::init()) // This
        .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:default"
    ]
}

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

pnpm add [email protected] -E
# or
npm install [email protected] --save-exact
# or
yarn add [email protected] --exact

NOTE: Please make sure that the Rust-side tauri-plugin-android-fs and the JavaScript-side tauri-plugin-android-fs-api versions match exactly.

Usage

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

When passing URIs to this plugin's functions, no scope configuration is required.
This is because the plugin only provides and accepts URIs whose permissions are already managed by the Android system, such as those explicitly selected by the user through a file picker or files created by the app in public directories.

Some functions accept not only URIs but also absolute paths, including app-specific directories. In this case, you need to set the scope configuration for security, like in plugin-fs.
You can set a global scope for the plugin, or assign specific scopes to individual commands:

src-tauri/capabilities/*.json

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

Examples

import { 
  AndroidFs, 
  AndroidPublicGeneralPurposeDir, 
  AndroidProgressNotificationIconType,
  type AndroidProgressNotificationTemplate 
} from 'tauri-plugin-android-fs-api';

/** 
 * Saves the data to '~/Download/MyApp/{fileName}'
 */
async function download(
  fileName: string,
  mimeType: string,
  data: Uint8Array | ReadableStream<Uint8Array>,
): Promise<void> {

  let uri;
  try {
    // Creates a new empty file
    uri = await AndroidFs.createNewPublicFile(
      AndroidPublicGeneralPurposeDir.Download,
      `MyApp/${fileName}`,
      mimeType,
      { isPending: true }
    );

    // Configures the system status bar notification (optional)
    const notification: AndroidProgressNotificationTemplate | undefined = {
      icon: AndroidProgressNotificationIconType.Download,
      title: "{{fileName}}",
      textProgress: "Downloading...",
      textCompletion: "Download complete",
      subText: "{{progress}}"
    };

    // Writes data to the file
    if (data instanceof Uint8Array) {
      await AndroidFs.writeFile(uri, data, { notification });
    }
    else if (data instanceof ReadableStream) {
      const writer = await AndroidFs.openWriteFileStream(uri, { notification });
      await data.pipeTo(writer);
    }
    else {
      throw new TypeError("Unsupported data type");
    }

    // Makes the file visible in other apps and gallery
    await AndroidFs.setPublicFilePending(uri, false);
    await AndroidFs.scanPublicFile(uri);
  }
  // Handles error and cleanup
  catch (e) {
    if (data instanceof ReadableStream) {
      await data.cancel(e).catch(() => { });
    }
    if (uri != null) {
      await AndroidFs.removeFile(uri).catch(() => { });
    }
    throw e;
  }
}

APIs

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.createDir
  • AndroidFs.createNewPublicFile
  • AndroidFs.createNewPublicImageFile
  • AndroidFs.createNewPublicVideoFile
  • AndroidFs.createNewPublicAudioFile

2. APIs to retrieve entry data

  • AndroidFs.getFsPath
  • AndroidFs.getMetadata
  • AndroidFs.getName
  • AndroidFs.getType
  • AndroidFs.getMimeType
  • AndroidFs.getByteLength
  • AndroidFs.getThumbnail
  • AndroidFs.getThumbnailAsBytes
  • AndroidFs.getThumbnailAsBase64
  • AndroidFs.getThumbnailAsDataURL

3. APIs to operate entries

  • AndroidFs.copyFile
  • AndroidFs.truncateFile
  • AndroidFs.renameFile
  • AndroidFs.renameDir
  • AndroidFs.removeFile
  • AndroidFs.removeEmptyDir
  • AndroidFs.removeDirAll
  • AndroidFs.scanPublicFile
  • AndroidFs.setPublicFilePending

4. APIs to read files

  • AndroidFs.openReadFileStream
  • AndroidFs.openReadTextFileLinesStream
  • AndroidFs.readFile
  • AndroidFs.readFileAsBase64
  • AndroidFs.readFileAsDataURL
  • AndroidFs.readTextFile

5. APIs to write to files

  • AndroidFs.openWriteFileStream
  • AndroidFs.writeFile
  • AndroidFs.writeTextFile

6. APIs to manage permissions

  • AndroidFs.checkPickerUriPermission
  • AndroidFs.persistPickerUriPermission
  • AndroidFs.checkPersistedPickerUriPermission
  • AndroidFs.releasePersistedPickerUriPermission
  • AndroidFs.releaseAllPersistedPickerUriPermissions
  • AndroidFs.checkPublicFilesPermission
  • AndroidFs.requestPublicFilesPermission

7. APIs to send entries to other apps

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

8. Helper

  • isAndroid
  • getAndroidApiLevel

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.