@gurjit_onebcg wrote:
Ionic version:
Ionic Framework Version: 3.0.1I have created a sample app to download a file in Mobile device
but when I click on download button, I see the download succeeded meessage. But image
does not appear in my PHOTOS .Current behavior:
Image is not appearing in PHOTOS .Expected behavior:
Downloaded image should appear in PHOTOS .Related code:
Type Script Code
"
import {Component} from ‘@angular/core’;
import {NavController, Platform, AlertController} from ‘ionic-angular’;
import {Transfer, TransferObject} from ‘@ionic-native/transfer’;
import {File} from ‘@ionic-native/file’;@Component({
selector: ‘page-home’,
templateUrl: ‘home.html’,
providers: [Transfer, TransferObject, File]
})export class HomePage {
storageDirectory: string = ‘’;
constructor(public navCtrl: NavController, public platform: Platform, private transfer: Transfer, private file: File, public alertCtrl: AlertController) {
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;
}this.storageDirectory = cordova.file.documentsDirectory;
});
}downloadImage(image) {
this.platform.ready().then(() => {
const fileTransfer: TransferObject = this.transfer.create();
const imageLocation = sourcePath;
fileTransfer.download(imageLocation, this.storageDirectory + image).then((entry) => {
const alertSuccess = this.alertCtrl.create({
title:Download Succeeded!
,
subTitle:${image} was successfully downloaded to: ${entry.toURL()}
,
buttons: [‘Ok’]
});alertSuccess.present();
Posts: 1
Participants: 1