@capgo/capacitor-downloader

Download file in background or foreground
WIP: the plugin is not yet ready for production
Install
npm install @capgo/capacitor-downloader
npx cap sync
API
download(...)
download(options: DownloadOptions) => Promise<DownloadTask>
Returns: Promise<DownloadTask>
pause(...)
pause(id: string) => Promise<void>
resume(...)
resume(id: string) => Promise<void>
stop(...)
stop(id: string) => Promise<void>
checkStatus(...)
checkStatus(id: string) => Promise<DownloadTask>
Returns: Promise<DownloadTask>
getFileInfo(...)
getFileInfo(path: string) => Promise<{ size: number; type: string; }>
Returns: Promise<{ size: number; type: string; }>
addListener('downloadProgress', ...)
addListener(eventName: 'downloadProgress', listenerFunc: (progress: { id: string; progress: number; }) => void) => Promise<PluginListenerHandle>
eventName | 'downloadProgress' |
listenerFunc | (progress: { id: string; progress: number; }) => void |
Returns: Promise<PluginListenerHandle>
addListener('downloadCompleted', ...)
addListener(eventName: 'downloadCompleted', listenerFunc: (result: { id: string; }) => void) => Promise<PluginListenerHandle>
eventName | 'downloadCompleted' |
listenerFunc | (result: { id: string; }) => void |
Returns: Promise<PluginListenerHandle>
addListener('downloadFailed', ...)
addListener(eventName: 'downloadFailed', listenerFunc: (error: { id: string; error: string; }) => void) => Promise<PluginListenerHandle>
eventName | 'downloadFailed' |
listenerFunc | (error: { id: string; error: string; }) => void |
Returns: Promise<PluginListenerHandle>
removeAllListeners()
removeAllListeners() => Promise<void>
Interfaces
DownloadTask
id | string |
progress | number |
state | 'PENDING' | 'RUNNING' | 'PAUSED' | 'DONE' | 'ERROR' |
DownloadOptions
id | string |
url | string |
destination | string |
headers | { [key: string]: string; } |
network | 'cellular' | 'wifi-only' |
priority | 'high' | 'normal' | 'low' |
PluginListenerHandle
remove | () => Promise<void> |
Credit
This plugin was inspired from: https://github.com/kesha-antonov/react-native-background-downloader