Zum Inhalt springen

Einstieg

Installieren

Terminal-Fenster
In die Zwischenablage kopieren
bun add @capgo/capacitor-downloader
bunx cap sync
import { CapacitorDownloader } from '@capgo/capacitor-downloader';

Ein neues Herunterladetask starten.

import { CapacitorDownloader } from '@capgo/capacitor-downloader';
const task = await Downloader.download({
id: 'my-download',
url: 'https://example.com/file.pdf',
destination: 'downloads/file.pdf'
});

Ein aktives Herunterladen pausieren. Das Herunterladen kann später von der gleichen Position fortgesetzt werden.

import { CapacitorDownloader } from '@capgo/capacitor-downloader';
await CapacitorDownloader.pause({} as { id: string });

Eine unterbrochene Herunterladung wieder aufnehmen. Fortsetzung von wo sie unterbrochen wurde.

import { CapacitorDownloader } from '@capgo/capacitor-downloader';
await CapacitorDownloader.resume({} as { id: string });

Eine Herunterladung dauerhaft stoppen und stornieren. Heruntergeladene Daten werden gelöscht.

import { CapacitorDownloader } from '@capgo/capacitor-downloader';
await CapacitorDownloader.stop({} as { id: string });

Den aktuellen Status einer Herunterladung überprüfen.

import { CapacitorDownloader } from '@capgo/capacitor-downloader';
await CapacitorDownloader.checkStatus({} as { id: string });

Informationen über ein heruntergeladenenes Datei erhalten.

import { CapacitorDownloader } from '@capgo/capacitor-downloader';
await CapacitorDownloader.getFileInfo({} as { path: string });

Konfigurationsoptionen für das Starten eines Downloads.

export interface DownloadOptions {
/** Unique identifier for this download task */
id: string;
/** URL of the file to download */
url: string;
/** Local file path where the download will be saved */
destination: string;
/** Optional HTTP headers to include in the request */
headers?: { [key: string]: string };
/** Network type requirement for download */
network?: 'cellular' | 'wifi-only';
/** Download priority level */
priority?: 'high' | 'normal' | 'low';
}

Stellt den aktuellen Zustand und den Fortschritt eines Downloadauftrags dar.

export interface DownloadTask {
/** Unique identifier for the download task */
id: string;
/** Download progress from 0 to 100 */
progress: number;
/** Current state of the download */
state: 'PENDING' | 'RUNNING' | 'PAUSED' | 'DONE' | 'ERROR';
}

Diese Seite wird aus dem Plugin generiert. src/definitions.tsRe-run die Synchronisation, wenn die öffentliche API upstream geändert wird.