@suyogN wrote:
Ionic: I am downloading images using
FileTransfer.download()it a success, but it won’t show in the
image gallery unless not relaunch the image gallery app.this.baseDownloadDir = ${this.file.externalRootDirectory}${this.userService.appName}/`; downloadImage(src: string): void { if (!this.userService.getNetworkState()) { this.loaderService.showToaster(this.translateService.instant('ERROR_MESSAGES.NO_NETWORK')); } else { if (src) { const fileName = src.split('/'); let imgName = fileName[fileName.length - 1]; imgName = imgName.replace('.', `${new Date().getTime().toString()}.`); const downloadPath = this.baseDownloadDir + imgName; this.fileTransfer = this.transfer.create(); this.diagnostic.isExternalStorageAuthorized().then((isAuthorized) => { if (isAuthorized) { this.fileDownload(src, downloadPath); } else { this.diagnostic.requestExternalStorageAuthorization().then((status) => { if (status === 'GRANTED') { this.fileDownload(src, downloadPath); } }); } }); } } } fileDownload(src, downloadPath) { this.fileTransfer.download(src, downloadPath).then((FileEntry) => { this.loaderService.showToaster(this.translateService.instant('ERROR_MESSAGES.DOWNLOAD_SUCCESS')); }); }
Posts: 1
Participants: 1