__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-fileをインストールし、リアルタイムでアップデートを管理することで、ストアの面倒を避け、5分で...

Capgo __CAPGO_KEEP_0__ リポジトリ

GitHub

CapgoのAI-Assisted Setupを使用してプラグインをインストールできます。AIツールにCapgoスキルを追加するには、以下のコマンドを実行してください。

ターミナルウィンドウ
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

次のプロンプトを使用してください。

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-file` plugin in my project.

Manual Setupを選択している場合、以下のコマンドを実行してプラグインをインストールし、下記のプラットフォーム固有の手順に従ってください。

ターミナル画面
bun add @capgo/capacitor-file
bunx cap sync
import { CapacitorFile } from '@capgo/capacitor-file';

ファイルシステムを要求します。

import { CapacitorFile, FileSystemType } from '@capgo/capacitor-file';
const result = await CapacitorFile.requestFileSystem({ type: FileSystemType.TEMPORARY });
console.log(result);

ファイルURLをエントリに解決する。

import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.resolveLocalFileSystemURL({ url: 'https://example.com' });
console.log(result);

ファイルエントリを取得する。

import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.getFile({ path: 'path/to/file' });
console.log(result);

ディレクトリエントリを取得する。

import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.getDirectory({ path: 'path/to/file' });
console.log(result);

テキストまたはbase64でファイルを読み込む。

import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.readFile({ path: 'path/to/file' });
console.log(result);

ファイルをデータURL (base64 MIMEタイププレフィックス)として読み取ります。

import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.readAsDataURL({ path: 'path/to/file' });
console.log(result);

ファイルにデータを書き込む。

import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.writeFile({
path: 'path/to/file',
data: 'data',
});
console.log(result);

ファイルにデータを追記する。

import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.appendFile({
path: 'path/to/file',
data: 'data',
});
console.log(result);

ファイルを削除する。

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.deleteFile({ path: 'path/to/file' });

ディレクトリを作成する

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.mkdir({ path: 'path/to/file' });

ディレクトリを削除する

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.rmdir({ path: 'path/to/file' });

ディレクトリの内容を読み取る

import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.readdir({ path: 'path/to/file' });
console.log(result);

ファイルまたはディレクトリのメタデータを取得する

import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.stat({ path: 'path/to/file' });
console.log(result);

ファイルまたはディレクトリのメタデータを取得します。 stat()のエイリアス。

import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.getMetadata({ path: 'path/to/file' });
console.log(result);

ファイルまたはディレクトリを名前変更または移動します。

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.rename({
from: 'from',
to: 'to',
});

ファイルまたはディレクトリを移動します。 rename()のエイリアス。

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.move({
from: 'from',
to: 'to',
});

ファイルまたはディレクトリをコピーします。

import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.copy({
from: 'from',
to: 'to',
});
console.log(result);

ファイルまたはディレクトリが存在するかどうかを確認します。

import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.exists({ path: 'path/to/file' });
console.log(result);

ファイルのURIを取得します。

import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.getUri({ path: 'path/to/file' });
console.log(result);

指定されたサイズにファイルを短縮します。

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.truncate({ path: 'path/to/file' });

すべてのファイルシステムディレクトリを取得します。

import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.getDirectories();
console.log(result);

バイト単位の空きディスクスペースを取得します。

import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.getFreeDiskSpace();
console.log(result);

ファイル操作の現在の許可状態を確認します。 Androidの場合、外部ストレージの許可を確認します。 iOSとWebの場合、特別な許可が必要ないため常に「許可済み」と表示されます。

import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.checkPermissions();
console.log(result);

ファイル操作の許可を要求します。 Androidの場合、外部ストレージの許可を要求して アプリのプライベートディレクトリ外のファイルにアクセスする必要があります。 iOSとWebの場合、特別な許可が必要ないため常に「許可済み」と表示されます。

import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.requestPermissions();
console.log(result);

ファイルシステムを要求するためのオプション

export interface RequestFileSystemOptions {
/** The type of file system to request */
type: FileSystemType;
/** Requested size in bytes (may not be enforced on all platforms) */
size?: number;
}

ファイルシステムを表します。

export interface FileSystem {
/** The name of the file system */
name: string;
/** The root directory of the file system */
root: DirectoryEntry;
}

URLをエントリに解決するためのオプション

export interface ResolveURLOptions {
/** The URL to resolve (file:// or cdvfile://) */
url: string;
}

ファイルまたはディレクトリエントリを表します。

export interface Entry {
/** True if this is a file */
isFile: boolean;
/** True if this is a directory */
isDirectory: boolean;
/** The name of the file or directory */
name: string;
/** The full path relative to the filesystem root */
fullPath: string;
/** The native file:// URI */
nativeURL: string;
}

ファイルを取得するためのオプション

export interface GetFileOptions {
/** Path to the file */
path: string;
/** Base directory */
directory?: Directory;
/** Options for creating the file */
options?: GetOptions;
}

ファイルエントリを表します。

export interface FileEntry extends Entry {
isFile: true;
isDirectory: false;
}

ディレクトリ取得のためのオプション

export interface GetDirectoryOptions {
/** Path to the directory */
path: string;
/** Base directory */
directory?: Directory;
/** Options for creating the directory */
options?: GetOptions;
}

ディレクトリエントリを表します。

export interface DirectoryEntry extends Entry {
isFile: false;
isDirectory: true;
}

ファイル読み取りのためのオプション

export interface ReadFileOptions {
/** Path to the file */
path: string;
/** Base directory */
directory?: Directory;
/** Encoding for text files (omit for binary/base64) */
encoding?: Encoding;
/** Byte offset to start reading from (default: 0) */
offset?: number;
/** Number of bytes to read (default: read to end of file) */
length?: number;
}

ファイルの読み取り結果。

export interface ReadFileResult {
/** File contents as string (text) or base64 (binary) */
data: string;
}

ファイルの書き込みオプション。

export interface WriteFileOptions {
/** Path to the file */
path: string;
/** Base directory */
directory?: Directory;
/** Data to write (string for text, base64 for binary) */
data: string;
/** Encoding for text files */
encoding?: Encoding;
/** If true, append to existing file instead of overwriting */
append?: boolean;
/** Create intermediate directories if they don't exist */
recursive?: boolean;
/** Byte position to start writing at (for random access writes). If not specified, writes from beginning or appends based on 'append' flag */
position?: number;
}

ファイルの書き込み結果。

export interface WriteFileResult {
/** The URI of the written file */
uri: string;
}

このページはプラグインから生成されます。 src/definitions.ts. 同期を再実行してください。 公開 API がアップストリームで変更されたとき。

あなたが使用している場合 Getting Started ストレージとファイルのハンドリングを計画するために使用している場合、接続してください。 @capgo/capacitorファイルを使用します。 Using @capgo/capacitor-file @capgo/capacitor-データストレージ-SQLite for the implementation detail in @capgo/capacitor-data-storage-sqlite Using @capgo/capacitor-data-storage-sqlite Capgoのネイティブ機能である@capgo/capacitor-data-storage-sqliteの使用 @capgo/capacitorファイル Capgoの実装詳細である@capgo/capacitor-fileの使用 @capgo/capacitorファイルアップローダ @capgo/capacitor-アップローダーの実装詳細のため。