Zum Inhalt springen

Getting Started

GitHub

Sie können unser AI-gestütztes Setup verwenden, um das Plugin zu installieren. Fügen Sie die Capgo-Fähigkeiten Ihrem AI-Tool mit dem folgenden Befehl hinzu:

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

Verwenden Sie dann die folgende Anweisung:

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

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

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

Einen neuen Download-Auftrag starten.

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

Ein aktives Download pausieren. Der Download kann später von der gleichen Position fortgesetzt werden.

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

Ein pausierten Download fortsetzen. Fortsetzt von der Position, an der er pausiert wurde.

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

Ein Download dauerhaft beenden und stornieren. Heruntergeladene Daten werden gelöscht.

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

Überprüfen Sie den aktuellen Status einer Herunterladung.

import { CapacitorDownloader } from '@capgo/capacitor-downloader';
const result = await CapacitorDownloader.checkStatus({ id: 'id-123' });
console.log(result);

Informationen über eine heruntergeladene Datei erhalten.

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

Konfigurationsoptionen für die Starten einer Herunterladung.

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 einer Downloadaufgabe 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 Synchronisierung, wenn die öffentliche API upstream geändert wird.

Wenn Sie das verwenden Getting Started um das Dashboard und die API-Operationen zu planen, verbinden Sie es mit Verwenden Sie @capgo/capacitor-downloader Einstellungen für die native Fähigkeit in Verwendung von @capgo/capacitor-downloader, Einstellungen API Einstellungen für die Implementierungsdetail in Einstellungen API, Einführung Einstellungen für die Implementierungsdetail in Einführung, API Keys für die Implementierungsdetails in API Schlüsseln und Geräte für die Implementierungsdetails in Geräten.