I’m try to download file form the external url below my code but its dose not working
Please helpme anyone.
download(){
let targetPath = this.file.documentsDirectory;
alert("hello")
this.file.createDir(targetPath,'video',true)
.then((res) => console.log('createDir video res',res))
.catch((err) => console.log('createDir video err',err));
const fileTransfer: FileTransferObject = this.transfer.create();
const url = "http://codersthought.com/sourav/videostatus/wp-content/uploads/2014/12/SampleVideo_1280x720_1mb.mp4";
var URL = encodeURI(url);
fileTransfer.download(URL, this.file.externalRootDirectory +'video/'+ 'SampleVideo_1280x720_1mb.mp4',true).then((entry) => {
console.log('download complete: ' + entry.toURL());
}, (error) => {
// handle error
});
}
Hi, @flycoders_sourav you are getting any error?
no am not getting any error
if you are using android platform use externalDataDirectory,
this.file.externalDataDirectory;
if you are using ios platform use documentsDirectory,
this.file.documentsDirectory;
its also not working bellow my code
let targetPath = this.file.documentsDirectory;
alert("hello")
this.file.createDir(targetPath,'video',true)
.then((res) => console.log('createDir video res',res))
.catch((err) => console.log('createDir video err',err));
const fileTransfer: FileTransferObject = this.transfer.create();
const url = "http://demo.com/sourav/videostatus/wp-content/uploads/2014/12d/SampleVideo_1280x720_1mb.mp4";
var URL = encodeURI(url);
fileTransfer.download(URL, this.file.externalDataDirectory +'video/'+ 'SampleVideo_1280x720_1mb.mp4',true).then((entry) => {
console.log('download complete: ' + entry.toURL());
}, (error) => {
// handle error
});
}
ok what response you are getting in console.log('download complete: ' + entry.toURL());
no am not getting any error
pls, print error like this,
}, (error) => {
console.log('err',error);
});
nothing happening in the console. also i give the value ot entry.toURL inside the alert
showing this error createDir video err cordova_not_available
ok, build your app in android or ios device and check.
I think your code is right but you need to check in real device and check your downloaded file in this path 'file:///storage/emulated/0/Android/data/your_app_name/files/video/SampleVideo_1280x720_1mb.mp4'
Which path do you want to change?
i cant find my app name folder inside the storage
Got it.but i want o change the download Katha locations and i want to download progress bar how can do that?
i want to change the download downloaded path how can i change that?
download path i want to change and i want to create a folder of my app name