Getting Started
Eine Setup-Vorlage mit den Installationsanweisungen und der vollständigen Markdown-Guideline für diesen Plugin kopieren.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-file-picker`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/file-picker/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
Installieren
Abschnitt mit dem Titel „Installieren“Sie können unsere AI-gestützte Einrichtung verwenden, um das Plugin zu installieren. Fügen Sie die Capgo-Fähigkeiten zu Ihrem KI-Tool hinzu, indem Sie die folgende Befehl ausführen:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsDann verwenden Sie die folgende Anfrage:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-file-picker` plugin in my project.Wenn Sie eine manuelle Einrichtung bevorzugen, installieren Sie das Plugin, indem Sie die folgenden Befehle ausführen und die darunter angegebenen Plattform-spezifischen Anweisungen befolgen:
bun add @capgo/capacitor-file-pickerbunx cap syncImportieren
Abschnitt mit dem Titel „Importieren“import { CapgoFilePicker } from '@capgo/capacitor-file-picker';API Übersicht
Abschnitt mit dem Titel „API Übersicht“Wählen Sie eine oder mehrere Dateien vom Gerät aus.
import { CapgoFilePicker } from '@capgo/capacitor-file-picker';
const result = await CapgoFilePicker.pickFiles({ types: ['application/pdf', 'image/*'], limit: 5, readData: false});console.log('Picked files:', result.files);Wählen Sie eine oder mehrere Bilder aus der Galerie. Nur für Android/iOS.
import { CapgoFilePicker } from '@capgo/capacitor-file-picker';
const result = await CapgoFilePicker.pickImages({ limit: 10, readData: false});console.log('Picked images:', result.files);pickVideos
Abschnitt mit dem Titel „pickVideos“Wählen Sie eine oder mehrere Videos aus der Galerie. Nur für Android/iOS.
import { CapgoFilePicker } from '@capgo/capacitor-file-picker';
const result = await CapgoFilePicker.pickVideos({ limit: 3, skipTranscoding: true});console.log('Picked videos:', result.files);pickMedia
Abschnitt mit dem Titel „pickMedia“Wählen Sie eine oder mehrere Bilder oder Videos aus der Galerie. Nur für Android/iOS.
import { CapgoFilePicker } from '@capgo/capacitor-file-picker';
const result = await CapgoFilePicker.pickMedia({ limit: 5, readData: true});console.log('Picked media:', result.files);pickDirectory
Abschnitt mit dem Titel „pickDirectory“Wählen Sie einen Ordner vom Gerät. Nur für Android/iOS.
import { CapgoFilePicker } from '@capgo/capacitor-file-picker';
const result = await CapgoFilePicker.pickDirectory();console.log('Selected directory:', result.path);convertHeicToJpeg
Abschnitt mit dem Titel „convertHeicToJpeg“Ein HEIC-Bild in JPEG-Format umwandeln. Nur für iOS.
import { CapgoFilePicker } from '@capgo/capacitor-file-picker';
const result = await CapgoFilePicker.convertHeicToJpeg({ path: '/path/to/image.heic', quality: 0.9});console.log('Converted file:', result.path);Ein Datei in einen neuen Ordner kopieren.
import { CapgoFilePicker } from '@capgo/capacitor-file-picker';
await CapgoFilePicker.copyFile({ from: '/source/file.pdf', to: '/destination/file.pdf', overwrite: true});checkPermissions
Abschnitt mit dem Titel „checkPermissions“Überprüfen Sie die Berechtigungen zum Lesen von Dateien. Nur für Android.
import { CapgoFilePicker } from '@capgo/capacitor-file-picker';
const status = await CapgoFilePicker.checkPermissions();console.log('Read permission:', status.readExternalStorage);requestPermissions
Abschnitt mit dem Titel „requestPermissions“Berechtigungen zum Lesen von Dateien anfordern. Nur für Android.
import { CapgoFilePicker } from '@capgo/capacitor-file-picker';
const status = await CapgoFilePicker.requestPermissions();if (status.readExternalStorage === 'granted') { console.log('Permission granted');}Typenreferenz
Abschnitt mit dem Titel “Typenreferenz”PickFilesOptions
Abschnitt mit dem Titel “Dateien auswählen”Einstellungen für die Auswahl von Dateien.
export interface PickFilesOptions { /** * List of accepted MIME types or file extensions. * On iOS, only MIME types are supported. * Examples: ['image/*'], ['application/pdf'], ['.pdf', '.doc'] */ types?: string[]; /** * Maximum number of files to pick. * Set to 0 for unlimited (platform default). * @default 0 */ limit?: number; /** * Whether to read the file data as base64. * Note: Reading large files may cause memory issues. * @default false */ readData?: boolean;}PickFilesResult
Abschnitt mit dem Titel “Auswahl von Dateien”Erfolg der Dateiauswahl.
export interface PickFilesResult { /** Array of picked files */ files: PickedFile[];}PickMediaOptions
Abschnitt mit dem Titel “Medien auswählen”Einstellungen für die Auswahl von Medien (Bildern/Videos).
export interface PickMediaOptions { /** * Maximum number of files to pick. * Set to 0 for unlimited (platform default). * @default 0 */ limit?: number; /** * Whether to read the file data as base64. * Note: Reading large files may cause memory issues. * @default false */ readData?: boolean; /** * iOS only: Skip transcoding of videos. * @default false */ skipTranscoding?: boolean; /** * iOS 15+ only: Show ordered selection badges. * @default false */ ordered?: boolean;}PickDirectoryResult
Abschnitt mit dem Titel “Verzeichnis auswählen”Erfolg der Verzeichnisauswahl.
export interface PickDirectoryResult { /** The path to the selected directory */ path: string;}ConvertHeicToJpegOptions
Abschnitt mit dem Titel “ConvertHeicToJpegOptions”Einstellungen für die Umwandlung von HEIC in JPEG.
export interface ConvertHeicToJpegOptions { /** The path to the HEIC file to convert */ path: string; /** * The compression quality for JPEG (0.0 - 1.0). * @default 0.9 */ quality?: number;}ConvertHeicToJpegResult
Abschnitt mit dem Titel “ConvertHeicToJpegResult”Ergebnis der Umwandlung von HEIC in JPEG.
export interface ConvertHeicToJpegResult { /** The path to the converted JPEG file */ path: string;}CopyFileOptions
Abschnitt mit dem Titel “CopyFileOptions”Einstellungen für die Kopie eines Dateisystems.
export interface CopyFileOptions { /** Source file path */ from: string; /** Destination file path */ to: string; /** * Whether to overwrite if destination exists. * @default false */ overwrite?: boolean;}PermissionStatus
Abschnitt mit dem Titel “PermissionStatus”Zugriffsstatus für Dateien.
export interface PermissionStatus { /** Whether permission to read media files is granted */ readExternalStorage: PermissionState; /** Whether permission to access media location is granted */ accessMediaLocation?: PermissionState;}PickerDismissedListener
Abschnitt mit dem Titel „PickerDismissedListener“Hinweis für den Abhörer beim Beenden des Pickers.
export type PickerDismissedListener = (event: null) => void;PickedFile
Abschnitt mit dem Titel „PickedFile“Ein ausgewähltes Dateiobjekt darstellt.
export interface PickedFile { /** The name of the file */ name: string; /** The path to the file */ path?: string; /** The MIME type of the file */ mimeType: string; /** The size of the file in bytes */ size: number; /** * The base64 encoded data of the file. * Only present if readData was true. */ data?: string; /** * The Blob instance of the file. * Web only. */ blob?: Blob; /** Width in pixels (images/videos only) */ width?: number; /** Height in pixels (images/videos only) */ height?: number; /** Duration in seconds (videos only) */ duration?: number; /** Last modified timestamp in milliseconds */ modifiedAt?: number;}PermissionState
Abschnitt mit dem Titel „PermissionState“Werte für die Berechtigungsanzeige.
export type PermissionState = 'prompt' | 'prompt-with-rationale' | 'granted' | 'denied';Quelle der Wahrheit
Abschnitt mit dem Titel „Quelle der Wahrheit“Diese Seite wird aus dem Plugin generiert. src/definitions.ts. Wiederholen Sie die Synchronisierung, wenn die öffentliche API upstream geändert wird.
Weitergehen von Getting Started
Abschnitt mit dem Titel „Weitergehen von Getting Started“Wenn Sie Storage und Dateihandling mit Getting Started planen, verbinden Sie es mit Getting Started Um Storage und Dateihandling zu planen, verbinden Sie es mit Verwenden Sie @capgo/capacitor-file-picker für die native Fähigkeit in Verwenden Sie @capgo/capacitor-file-picker Verwenden Sie @capgo/capacitor-data-storage-sqlite für die Implementierungsdetail in Verwenden Sie @capgo/capacitor-data-storage-sqlite Verwenden Sie @capgo/capacitor-data-storage-sqlite für die native Fähigkeit in Verwendung von @capgo/capacitor-data-storage-sqlite, @capgo/capacitor-file für die Implementierungsdetails in @capgo/capacitor-file und Verwendung von @capgo/capacitor-file für die native Fähigkeit in Verwendung von @capgo/capacitor-file.