从s3下载的图片,如何保存

时间:2017-10-31 13:39:41

标签: html image ionic-framework amazon-s3 mobile-application

从s3下载图像后,我在'Body'中获得了一些位。以前,我将这些位编码到base64中,并直接在<img>标记中显示它们。

但是现在,我想将它们保存到文件系统(android / iOS)中的“真实”文件(.jpg / png)中,然后给出html(背景)标记的路径。

  

(它会起作用吗?)

我是否仍然需要将从S3获得的一堆位转换为base64然后保存它还是有更简单的方法?

1 个答案:

答案 0 :(得分:0)

You can use the plugin cordova-plugin-file for saving file  locally to your filesystem.

Like this
var url = url;
    var targetPath = cordova.file.externalDataDirectory + NAME;
    //alert(targetPath);
    var trustHosts = true;
    var options = {};

$cordovaFileTransfer.download(url, targetPath, options, trustHosts)

I think you can give the local file address to img src..
相关问题