@himeka/capacitor-plugin-filedownload
v1.0.6
Published
A file download plugin for capacitor3.0+
Downloads
5
Maintainers
Readme
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>
| 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 |