Zum Inhalt springen

Getting Started

GitHub

Sie können unsere AI-gestützte Einrichtung verwenden, um das Plugin zu installieren. Fügen Sie den Capgo-Fähigkeiten Ihrer AI-Werkzeugleiste mit folgendem Befehl hinzu:

Terminalfenster
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

Verwenden Sie dann folgende Anfrage:

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

Wenn Sie die manuelle Einrichtung bevorzugen, installieren Sie das Plugin, indem Sie die folgenden Befehle ausführen und folgen Sie den unten angegebenen Plattform-spezifischen Anweisungen:

Terminalfenster
bun add @capgo/capacitor-file
bunx cap sync
import { CapacitorFile } from '@capgo/capacitor-file';

Einen Dateisystemanforderung stellen.

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.requestFileSystem({} as RequestFileSystemOptions);

Eine Datei-URL auf einen Eintrag auflösen.

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.resolveLocalFileSystemURL({} as ResolveURLOptions);

Einen Dateieintrag erhalten.

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.getFile({} as GetFileOptions);

Einen Verzeichniseintrag erhalten.

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.getDirectory({} as GetDirectoryOptions);

Ein Datei als Text oder Base64 lesen.

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.readFile({} as ReadFileOptions);

Eine Datei als Daten-URL (Base64 mit MIME-Typ-Präfix) lesen.

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.readAsDataURL({} as ReadFileOptions);

Daten in eine Datei schreiben.

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.writeFile({} as WriteFileOptions);

Daten einer Datei anhängen.

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.appendFile({} as WriteFileOptions);

Ein Datei löschen.

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.deleteFile({} as DeleteFileOptions);

Eine Verzeichnis erstellen.

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.mkdir({} as MkdirOptions);

Ein Verzeichnis löschen.

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.rmdir({} as DeleteDirectoryOptions);

Verzeichnisinhalt lesen.

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.readdir({} as ReaddirOptions);

Ermitteln Sie Informationen über ein Dateisystem-Objekt.

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.stat({} as StatOptions);

Ermitteln Sie Informationen über ein Dateisystem-Objekt. Alias für stat().

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.getMetadata({} as StatOptions);

Umbenennen oder verschieben Sie ein Dateisystem-Objekt.

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.rename({} as RenameOptions);

Verschieben Sie ein Dateisystem-Objekt. Alias für rename().

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.move({} as RenameOptions);

Einen Datei- oder Verzeichnis-Ordner kopieren.

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.copy({} as CopyOptions);

Überprüfen, ob eine Datei oder ein Verzeichnis existiert.

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.exists({} as ExistsOptions);

Ermitteln Sie die URI für eine Datei.

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.getUri({} as GetUriOptions);

Eine Datei auf eine bestimmte Größe trancieren.

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.truncate({} as TruncateOptions);

Alle bekannten Dateisystemverzeichnisse abrufen.

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.getDirectories();

Die verfügbare Festplattenplatzgröße in Bytes abrufen.

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.getFreeDiskSpace();

Überprüfen Sie den aktuellen Berechtigungsstatus für Dateibearbeitungen. Bei Android-Systemen überprüft dies die externen Speicherberechtigungen. Bei iOS- und Web-Systemen wird immer ‘erlaubt’ zurückgegeben, da keine besonderen Berechtigungen erforderlich sind.

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.checkPermissions();

Anfragen Sie die Berechtigungen für Dateibearbeitungen. Bei Android-Systemen werden externe Speicherberechtigungen angefordert, die für den Zugriff auf Dateien außerhalb der privaten Verzeichnisse des Apps erforderlich sind. Bei iOS- und Web-Systemen wird immer ‘erlaubt’ zurückgegeben, da keine besonderen Berechtigungen erforderlich sind.

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.requestPermissions();

Optionen für die Anforderung eines Dateisystems.

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;
}

Darstellt ein Dateisystem.

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

Optionen für die Auflösung einer URL zu einem Eintrag.

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

Entry

Eingabe

Stellt einen Datei- oder Verzeichnis-Eintrag dar.

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;
}

Einstellungen für die Datei-Eingabe.

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

In die Zwischenablage kopieren

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

Einstellungen für die Datei-Eingabe.

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

Stellt einen Verzeichniseintrag dar.

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

Optionen für das Lesen eines Dateisystems.

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;
}

Ergebnis des Lesens eines Dateisystems.

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

Optionen für das Schreiben eines Dateisystems.

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;
}

Ergebnis der Dateischreibvorgang

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

Diese Seite wurde aus dem Plugin generiert. Wenn sich die öffentliche __CAPGO_KEEP_0__ im Hintergrund ändert, führen Sie die Synchronisation erneut durch. src/definitions.ts. Re-run the sync when the public API changes upstream.

Abschnitt mit dem Titel “Fortsetzung von Getting Started”

Wenn Sie

Getting Started zur Planung von Speicher und Dateimanagement verwenden, verbinden Sie es mit Abschnitt mit dem Titel “Getting Started” Mit @capgo/capacitor-Datei für die native Fähigkeit in Mit @capgo/capacitor-Datei @capgo/capacitor-Daten-Speicher-SQLite für die Implementierungsdetails in @capgo/capacitor-Daten-Speicher-SQLite Mit @capgo/capacitor-Daten-Speicher-SQLite für die native Fähigkeit in Mit @capgo/capacitor-Daten-Speicher-SQLite @capgo/capacitor-Datei für die Implementierungsdetails in @capgo/capacitor-Datei und @capgo/capacitor-Uploader für die Implementierungsdetails in @capgo/capacitor-Uploader.