ファイルシステム
ファイルシステムへのアクセス、ファイルの読み取り、書き込み、一覧表示、情報の取得。
This plugin requires a Rust version of at least 1.77.2
| Platform | Level | Notes |
|---|---|---|
| windows | Apps installed via MSI or NSIS in | |
| linux | No write access to | |
| macos | No write access to | |
| android | | Access is restricted to Application folder by default |
| ios | | Access is restricted to Application folder by default |
ファイルシステムプラグインをインストールして開始します。
プロジェクトのパッケージマネージャーを使用して依存関係を追加します。
npm run tauri add fsyarn run tauri add fspnpm tauri add fsdeno task tauri add fsbun tauri add fscargo tauri add fs-
src-tauriフォルダで次のコマンドを実行して、Cargo.tomlのプロジェクトの依存関係にプラグインを追加します。cargo add tauri-plugin-fs -
lib.rsを変更してプラグインを初期化します。src-tauri/src/lib.rs #[cfg_attr(mobile, tauri::mobile_entry_point)]pub fn run() {tauri::Builder::default().plugin(tauri_plugin_fs::init()).run(tauri::generate_context!()).expect("error while running tauri application");} -
JavaScript からファイルシステムにアクセスしたい場合は、npm パッケージもインストールします。
npm install @tauri-apps/plugin-fsyarn add @tauri-apps/plugin-fspnpm add @tauri-apps/plugin-fsdeno add npm:@tauri-apps/plugin-fsbun add @tauri-apps/plugin-fs
ファイルシステムプラグインは、JavaScript と Rust の両方で使用できます。
import { exists, readTextFile, writeTextFile, BaseDirectory,} from '@tauri-apps/plugin-fs';
// `$APP_DATA/avatar.png` が存在するか確認しますawait exists('avatar.png', { baseDir: BaseDirectory.AppData });
// テキストファイルを読み取りますconst contents = await readTextFile('app.conf', { baseDir: BaseDirectory.AppConfig,});
// ファイルにテキストを書き込みますawait writeTextFile('app.conf', 'file contents', { baseDir: BaseDirectory.AppConfig,});Rust API は std::fs に似ていますが、セキュリティスコープの適用が追加されています。
use tauri_plugin_fs::FsExt;
let scope = app.fs_scope(); // または app_handle.fs_scope()
// スコープで許可されたディレクトリ内でのみアクセス可能ですlet file_path = "/path/to/file";if scope.is_allowed(file_path) { println!("File access allowed");} else { println!("File access forbidden");}デフォルトでは、すべての潜在的に危険なプラグインコマンドとスコープはブロックされており、アクセスできません。これらを有効にするには、capabilities 設定の権限を変更する必要があります。
詳細については、機能の概要 と、プラグイン権限を使用するための ステップバイステップガイド を参照してください。
{ "permissions": [ ..., "fs:default", // 権限スコープを有効にします "fs:allow-app-data-recursive", "fs:allow-app-config-recursive", // 拡張スコープ: `$HOME/images` へのアクセスを許可します { "identifier": "fs:allow-home-read-recursive", "allow": [{ "path": "$HOME/images" }] } ]}Default Permission
This set of permissions describes the what kind of
file system access the fs plugin has enabled or denied by default.
Granted Permissions
This default permission set enables read access to the application specific directories (AppConfig, AppData, AppLocalData, AppCache, AppLog) and all files and sub directories created in it. The location of these directories depends on the operating system, where the application is run.
In general these directories need to be manually created by the application at runtime, before accessing files or folders in it is possible.
Therefore, it is also allowed to create all of these folders via
the mkdir command.
Denied Permissions
This default permission set prevents access to critical components of the Tauri application by default. On Windows the webview data folder access is denied.
This default permission set includes the following:
create-app-specific-dirsread-app-specific-dirs-recursivedeny-default
Permission Table
| Identifier | Description |
|---|---|
|
|
This allows full recursive read access to the complete application folders, files and subdirectories. |
|
|
This allows full recursive write access to the complete application folders, files and subdirectories. |
|
|
This allows non-recursive read access to the application folders. |
|
|
This allows non-recursive write access to the application folders. |
|
|
This allows full recursive read access to metadata of the application folders, including file listing and statistics. |
|
|
This allows non-recursive read access to metadata of the application folders, including file listing and statistics. |
|
|
This scope permits recursive access to the complete application folders, including sub directories and files. |
|
|
This scope permits access to all files and list content of top level directories in the application folders. |
|
|
This scope permits to list all files and folders in the application directories. |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
This allows full recursive read access to the complete |
|
|
This allows full recursive write access to the complete |
|
|
This allows non-recursive read access to the |
|
|
This allows non-recursive write access to the |
|
|
This allows full recursive read access to metadata of the |
|
|
This allows non-recursive read access to metadata of the |
|
|
This scope permits recursive access to the complete |
|
|
This scope permits access to all files and list content of top level directories in the |
|
|
This scope permits to list all files and folders in the |
|
|
Enables the copy_file command without any pre-configured scope. |
|
|
Denies the copy_file command without any pre-configured scope. |
|
|
Enables the create command without any pre-configured scope. |
|
|
Denies the create command without any pre-configured scope. |
|
|
Enables the exists command without any pre-configured scope. |
|
|
Denies the exists command without any pre-configured scope. |
|
|
Enables the fstat command without any pre-configured scope. |
|
|
Denies the fstat command without any pre-configured scope. |
|
|
Enables the ftruncate command without any pre-configured scope. |
|
|
Denies the ftruncate command without any pre-configured scope. |
|
|
Enables the lstat command without any pre-configured scope. |
|
|
Denies the lstat command without any pre-configured scope. |
|
|
Enables the mkdir command without any pre-configured scope. |
|
|
Denies the mkdir command without any pre-configured scope. |
|
|
Enables the open command without any pre-configured scope. |
|
|
Denies the open command without any pre-configured scope. |
|
|
Enables the read command without any pre-configured scope. |
|
|
Denies the read command without any pre-configured scope. |
|
|
Enables the read_dir command without any pre-configured scope. |
|
|
Denies the read_dir command without any pre-configured scope. |
|
|
Enables the read_file command without any pre-configured scope. |
|
|
Denies the read_file command without any pre-configured scope. |
|
|
Enables the read_text_file command without any pre-configured scope. |
|
|
Denies the read_text_file command without any pre-configured scope. |
|
|
Enables the read_text_file_lines command without any pre-configured scope. |
|
|
Denies the read_text_file_lines command without any pre-configured scope. |
|
|
Enables the read_text_file_lines_next command without any pre-configured scope. |
|
|
Denies the read_text_file_lines_next command without any pre-configured scope. |
|
|
Enables the remove command without any pre-configured scope. |
|
|
Denies the remove command without any pre-configured scope. |
|
|
Enables the rename command without any pre-configured scope. |
|
|
Denies the rename command without any pre-configured scope. |
|
|
Enables the seek command without any pre-configured scope. |
|
|
Denies the seek command without any pre-configured scope. |
|
|
Enables the size command without any pre-configured scope. |
|
|
Denies the size command without any pre-configured scope. |
|
|
Enables the stat command without any pre-configured scope. |
|
|
Denies the stat command without any pre-configured scope. |
|
|
Enables the truncate command without any pre-configured scope. |
|
|
Denies the truncate command without any pre-configured scope. |
|
|
Enables the unwatch command without any pre-configured scope. |
|
|
Denies the unwatch command without any pre-configured scope. |
|
|
Enables the watch command without any pre-configured scope. |
|
|
Denies the watch command without any pre-configured scope. |
|
|
Enables the write command without any pre-configured scope. |
|
|
Denies the write command without any pre-configured scope. |
|
|
Enables the write_file command without any pre-configured scope. |
|
|
Denies the write_file command without any pre-configured scope. |
|
|
Enables the write_text_file command without any pre-configured scope. |
|
|
Denies the write_text_file command without any pre-configured scope. |
|
|
This permissions allows to create the application specific directories. |
|
|
This denies access to dangerous Tauri relevant files and folders by default. |
|
|
This denies read access to the
|
|
|
This denies read access to the
|
|
|
This enables all read related commands without any pre-configured accessible paths. |
|
|
This permission allows recursive read functionality on the application specific base directories. |
|
|
This enables directory read and file metadata related commands without any pre-configured accessible paths. |
|
|
This enables file read related commands without any pre-configured accessible paths. |
|
|
This enables all index or metadata related commands without any pre-configured accessible paths. |
|
|
An empty permission you can use to modify the global scope. Example
|
|
|
This enables all write related commands without any pre-configured accessible paths. |
|
|
This enables all file write related commands without any pre-configured accessible paths. |
© 2025 Tauri Contributors. CC-BY / MIT