如何使用离子将图像从URL保存到设备照片库? [英] How to save image from URL into device photo gallery using ionic?

查看:94
本文介绍了如何使用离子将图像从URL保存到设备照片库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是离子新手,我正在开发应用程序中使用离子的应用程序。当用户点击下载按钮时,我需要将图像下载到用户设备。我搜索了很多,但我找不到任何合适的解决方案。

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.

推荐答案

你可以使用转移 插件来自 ionic-本地

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

这篇关于如何使用离子将图像从URL保存到设备照片库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆