1.0.6 • Published 6 months ago

@himeka/capacitor-plugin-filedownload v1.0.6

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

capacitor-plugin-filedownload

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>
ParamType
optionsFileDownloadOptions

Returns: Promise<FileDownloadResponse>


addListener('downloadProgress', ...)

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

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


Interfaces

FileDownloadResponse

PropType
pathstring

FileDownloadOptions

PropType
uristring
fileNamestring

PluginListenerHandle

PropType
remove() => Promise<void>

FileDownloadProgress

PropType
progressnumber
1.0.6

6 months ago

1.0.5

8 months ago