@himeka/capacitor-plugin-filedownload
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

capacitor-plugin-filedownload

A file download plugin for capacitor3.0+

Install

npm install @himeka/capacitor-plugin-filedownload
npx cap sync

eg:

import { FileDownload } from "@himeka/capacitor-plugin-filedownload";

FileDownload.download({
  uri: "http://www.xxxxx.com/file/rvh.apk",
  fileName: "release.apk"
}).then((res) => {
  console.log(res.path);
}).catch(err => {
  console.log(err);
})

/* Not implemented

const eventListener = await FileDownload.addListener('downloadProgress', data =>{
  console.log(data.progress);
})

// remove eventListener
eventListener.remove();

*/
...

if you wish to open the file, you can install this plugin: https://github.com/capacitor-community/file-opener

API

download(...)

download(options: FileDownloadOptions) => Promise<FileDownloadResponse>
Param Type
options FileDownloadOptions

Returns: Promise<FileDownloadResponse>


addListener('downloadProgress', ...)

addListener(eventName: 'downloadProgress', listenerFunc: (progress: FileDownloadProgress) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param Type
eventName 'downloadProgress'
listenerFunc (progress: FileDownloadProgress) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


Interfaces

FileDownloadResponse

Prop Type
path string

FileDownloadOptions

Prop Type
uri string
fileName string

PluginListenerHandle

Prop Type
remove () => Promise<void>

FileDownloadProgress

Prop Type
progress number

Package Sidebar

Install

npm i @himeka/capacitor-plugin-filedownload

Weekly Downloads

2

Version

1.0.6

License

MIT

Unpacked Size

30.3 kB

Total Files

28

Last publish

Collaborators

  • himeka