Passer au contenu

Débuter

GitHub

Vous pouvez utiliser notre configuration assistée par l'IA pour installer le plugin. Ajoutez les Capgo compétences à votre outil IA en utilisant la commande suivante :

Fenêtre de terminal
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

Ensuite, utilisez la prompt suivante :

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

Si vous préférez la configuration manuelle, installez le plugin en exécutant les commandes suivantes et suivez les instructions spécifiques à la plateforme ci-dessous :

Fenêtre de terminal
bun add @capgo/capacitor-downloader
bunx cap sync
import { CapacitorDownloader } from '@capgo/capacitor-downloader';

Lancer une nouvelle tâche de téléchargement.

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

Mettre en pause une téléchargement en cours. Le téléchargement peut être repris ultérieurement à la même position.

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

Résumer une téléchargement en pause. Continue à partir de l'endroit où il était en pause.

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

Arrêter et annuler un téléchargement définitivement. Les données téléchargées seront supprimées.

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

Vérifier l'état actuel d'un téléchargement.

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

Obtenir des informations sur un fichier téléchargé.

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

Référence de type

Référence de type

Options de configuration pour démarrer un téléchargement.

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

Représente l'état actuel et le progrès d'une tâche de téléchargement.

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

Re-run la synchronisation lorsque les modifications publiques __CAPGO_KEEP_0__ changent en amont. src/definitions.ts. Re-run the sync when the public API changes upstream.

Si vous utilisez Accueil pour planifier votre tableau de bord et les opérations API, connectez-l’avec En utilisant @capgo/capacitor-downloader pour la capacité native en utilisant @capgo/capacitor-downloader, Vue d'ensemble de API pour les détails d'implémentation dans Vue d'ensemble de API, Introduction pour les détails d'implémentation dans Introduction, Clés de API pour les détails d'implémentation dans Clés de API, Appareils pour le détail d'implémentation dans Appareils.