How to save image from URL into device photo galle

2019-08-07 07:51发布

问题:

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
  });