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

Ein Dateieintrag erhalten.

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

Ein 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);

Inhalte des Verzeichnisses lesen.

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

Ermitteln Sie Informationen über ein Dateisystem oder eine Datei.

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

Ermitteln Sie Informationen über ein Dateisystem oder eine Datei. Alias für stat().

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

Umbenennen oder verschieben Sie ein Dateisystem oder eine Datei.

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

Verschieben Sie ein Dateisystem oder eine Datei. 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();

Berechtigungen für Dateibearbeitungen anfordern. Bei Android-Systemen werden die externen Speicherberechtigungen erforderlich, um auf Dateien außerhalb der privaten Verzeichnisse des Apps zuzugreifen. 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();

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

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

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

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

Optionen zum Abrufen einer Datei.

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

Stellt einen Datei-Eintrag dar.

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

Optionen zum Abrufen eines Verzeichnisses.

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 der Dateiläsung.

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

Erfolg der Dateischreibaufgabe.

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

Diese Seite wurde aus dem Plugin generiert. src/definitions.tsLäuft die öffentliche API-Synchronisation neu, wenn sich die Quelle ändert.

Wenn Sie Datei- und Speicherplatzplanung mit Anfang an verwenden, verbinden Sie es mit 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.