Skip to content

Cap-go/capacitor-downloader

@capgo/capacitor-downloader

Capgo - Instant updates for capacitor

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>
Param Type
options DownloadOptions

Returns: Promise<DownloadTask>


pause(...)

pause(id: string) => Promise<void>
Param Type
id string

resume(...)

resume(id: string) => Promise<void>
Param Type
id string

stop(...)

stop(id: string) => Promise<void>
Param Type
id string

checkStatus(...)

checkStatus(id: string) => Promise<DownloadTask>
Param Type
id string

Returns: Promise<DownloadTask>


getFileInfo(...)

getFileInfo(path: string) => Promise<{ size: number; type: string; }>
Param Type
path string

Returns: Promise<{ size: number; type: string; }>


addListener('downloadProgress', ...)

addListener(eventName: 'downloadProgress', listenerFunc: (progress: { id: string; progress: number; }) => void) => Promise<PluginListenerHandle>
Param Type
eventName 'downloadProgress'
listenerFunc (progress: { id: string; progress: number; }) => void

Returns: Promise<PluginListenerHandle>


addListener('downloadCompleted', ...)

addListener(eventName: 'downloadCompleted', listenerFunc: (result: { id: string; }) => void) => Promise<PluginListenerHandle>
Param Type
eventName 'downloadCompleted'
listenerFunc (result: { id: string; }) => void

Returns: Promise<PluginListenerHandle>


addListener('downloadFailed', ...)

addListener(eventName: 'downloadFailed', listenerFunc: (error: { id: string; error: string; }) => void) => Promise<PluginListenerHandle>
Param Type
eventName 'downloadFailed'
listenerFunc (error: { id: string; error: string; }) => void

Returns: Promise<PluginListenerHandle>


removeAllListeners()

removeAllListeners() => Promise<void>

Interfaces

DownloadTask

Prop Type
id string
progress number
state 'PENDING' | 'RUNNING' | 'PAUSED' | 'DONE' | 'ERROR'

DownloadOptions

Prop Type
id string
url string
destination string
headers { [key: string]: string; }
network 'cellular' | 'wifi-only'
priority 'high' | 'normal' | 'low'

PluginListenerHandle

Prop Type
remove () => Promise<void>

Credit

This plugin was inspired from: https://github.com/kesha-antonov/react-native-background-downloader

About

Capacitor plugin to download file in background or foreground

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 3

  •  
  •  
  •