I am new to ionic and I am developing application using ionic in the application. I need to download the image to the user device when user click on download button. I searched a lot but I am not able to find any proper solution.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can use Transfer
plugin from ionic-native
.
import { Transfer } from 'ionic-native';
declare var cordova: any;
download() {
const fileTransfer = new Transfer();
let url = 'http://www.example.com/file.pdf';
fileTransfer.download(url, cordova.file.dataDirectory + 'file.pdf').then((entry) => {
console.log('download complete: ' + entry.toURL());
}, (error) => {
// handle error
});
标签:
ionic-framework