File download in custom directory in internal memory


#1

When download the file on that time i want to create a folder of my app name
Below my code

 

this.platform.ready().then(() => {
// make sure this is on a device, not an emulation (e.g. chrome tools device mode)
if(!this.platform.is(‘cordova’)) {
return false;
}

		if (this.platform.is('ios')) {
			this.storageDirectory = cordova.file.documentsDirectory;
		}
		else if(this.platform.is('android')) {
			this.storageDirectory = cordova.file.externalDataDirectory;
		}
		else {
			// exit otherwise, but you could add further types here e.g. Windows
			return false;
		}
	});
download(event,item){
	this.presentToast('Download started..');
	this.platform.ready().then(() => {

	const fileTransfer: FileTransferObject = this.transfer.create();
	let getUrl = this.selectedItem._meta_video_status
	let downloadFileName = getUrl.substr(getUrl.lastIndexOf('/') + 1); 
	//const imageLocation = `${cordova.file.applicationDirectory}www/assets/img/${item}`;
	const url =   getUrl;
	var URL = encodeURI(url);
	this.loading = this.loadingCtrl.create({
		content: 'Downloading...',
		});
	this.loading.present();
	fileTransfer.download(URL, this.storageDirectory+ downloadFileName).then((entry) => {
	this.loading.dismissAll();
	this.presentToast('Download complete !');
	}, (error) => {
	 this.presentToast('Download faild, please try again !');
			});
		});
}
Please help me anyone
Thanks