7.0.2 • Published 11 months ago

@capgo/capacitor-downloader v7.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

@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>
ParamType
optionsDownloadOptions

Returns: Promise<DownloadTask>


pause(...)

pause(id: string) => Promise<void>
ParamType
idstring

resume(...)

resume(id: string) => Promise<void>
ParamType
idstring

stop(...)

stop(id: string) => Promise<void>
ParamType
idstring

checkStatus(...)

checkStatus(id: string) => Promise<DownloadTask>
ParamType
idstring

Returns: Promise<DownloadTask>


getFileInfo(...)

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

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


addListener('downloadProgress', ...)

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

Returns: Promise<PluginListenerHandle>


addListener('downloadCompleted', ...)

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

Returns: Promise<PluginListenerHandle>


addListener('downloadFailed', ...)

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

Returns: Promise<PluginListenerHandle>


removeAllListeners()

removeAllListeners() => Promise<void>

Interfaces

DownloadTask

PropType
idstring
progressnumber
state'PENDING' | 'RUNNING' | 'PAUSED' | 'DONE' | 'ERROR'

DownloadOptions

PropType
idstring
urlstring
destinationstring
headers{ key: string: string; }
network'cellular' | 'wifi-only'
priority'high' | 'normal' | 'low'

PluginListenerHandle

PropType
remove() => Promise<void>

Credit

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

7.0.2

11 months ago

7.0.1

12 months ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.8

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago