其他分享
首页 > 其他分享> > ionic 文件下载

ionic 文件下载

作者:互联网

注意,只能用于http/https去下载文件

依赖:

npm install @ionic-native/downloader integrator-cordova-plugin-downloader

import { Downloader } from '@ionic-native/downloader/ngx';


constructor(private downloader: Downloader) { }

...

   var request: DownloadRequest = {
          uri: YOUR_URI,
          title: 'MyDownload',
          description: '',
          mimeType: '',
          visibleInDownloadsUi: true,
          notificationVisibility: NotificationVisibility.VisibleNotifyCompleted,
          destinationInExternalFilesDir: {
              dirType: 'Downloads',
              subPath: 'MyFile.apk'
          }
      };


  this.downloader.download(request)
              .then((location: string) => console.log('File downloaded at:'+location))
              .catch((error: any) => console.error(error));

 

标签:文件,console,downloader,location,error,ionic,下载,native
来源: https://www.cnblogs.com/hello-dummy/p/16425684.html