How download a file from external url using ionic2?


#1

i need to download file from external url like “htttp://ww.xyz.com/32323232.mp3” on my button click please any one help me to do this functionality in my app .i am eagerly waiting for your reply friends


#2

use file transfer plugin


#3

Any reference link please


#4

#5

thank you i try this and let you know


#6

i have tried this its working but how to know download start


#7

Try LoadingController , when your download is beginning a loader will be showed in your view after the download is ok the loader will be hidden and you can start any function :

add import { LoadingController } from 'ionic-angular';

add loader:any;

add `public loadingCtrl: LoadingController to constructor

in your constructor or any function you can create a loader :

this.loader = this.loadingCtrl.create({
      content: "Wait download ..",
	  spinner:"dots"
    });

before code of download present your loader :
this.loader.present();

after code hide loader :
this.loader.dismiss()


#8

on android 6,0.1 i am getting error for any think i need to add it in config.xml?


#9

upgrade your cordova plugin to Cordova Android 6.2.3 or Cordova Android 6.2.2


#10
<engine name="android" spec="^6.2.3" />   
 <plugin name="cordova-plugin-console" spec="^1.0.5" />
<plugin name="cordova-plugin-device" spec="^1.1.4" />
<plugin name="cordova-plugin-file-transfer" spec="^1.6.3" />
<plugin name="cordova-plugin-splashscreen" spec="^4.0.3" />
<plugin name="cordova-plugin-statusbar" spec="^2.2.2" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.1" />
<plugin name="ionic-plugin-keyboard" spec="^2.2.1" />

this is in config.xml


#11

No , juste look here How to update cordova and ionic?


#12

Is there really a compelling reason to use a Cordova plugin here instead of just good old Angular Http?


#13

i am not understood what your saying here


#14

I am saying “what is wrong with http.get("url/of/thing.mp3")?”


#15

using this download audio files in real device


#16

Isn’t that what you said you wanted to do?