Guide
Tutoriel sur le Téléchargement
Utilisation de @capgo/capacitor-downloader
Capacitor plugin pour télécharger des fichiers avec un support de fond. Fournit des téléchargements résumables avec une suivi de progression.
Installer
bun add @capgo/capacitor-downloader
bunx cap sync
Ce que ce Plugin Expose
download- Lancer une nouvelle tâche de téléchargement.pause- Mettre en pause un téléchargement actif. Le téléchargement peut être repris ultérieurement à la même position.resume- Reprendre un téléchargement mis en pause. Continue à partir de l'endroit où il était mis en pause.stop- Arrêtez et annulez une téléchargement définitivement. Les données téléchargées seront supprimées.
Exemple d'utilisation
download
Lancer un nouveau 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'
});
pause
Mettez en pause un téléchargement actif. 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 });
resume
Reprendre un téléchargement en pause. Continue à partir de l'endroit où il était arrêté.
import { CapacitorDownloader } from '@capgo/capacitor-downloader';
await CapacitorDownloader.resume({} as { id: string });
stop
Arrêtez et annulez 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 });
Référence complète
- GitHub https://github.com/Cap-go/capacitor-downloader/
- Documentation : /docs/plugins/downloader/