Phonegap:将base64图像保存到图库 [英] Phonegap: save base64 image to gallery
本文介绍了Phonegap:将base64图像保存到图库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想保存图片base64并在图库中打开它。我不想从图片库中拍照或拍照。
I just wanna save an image base64 and open it on gallery. I don't want to get pictures from gallery or take pictures.
<img src="base64" />
<button>Save</button>
phonegap + angularjs
phonegap + angularjs
谢谢! / p>
Thanks!
推荐答案
解决方案:
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {
var fileTransfer = new FileTransfer();
var uri = encodeURI("http://www.example.com/image");
var path = fileSystem.root.toURL() + "appName/example.jpg";
fileTransfer.download(
uri,
path,
function(entry) {
refreshMedia.refresh(path); // Refresh the image gallery
},
function(error) {
console.log(error.source);
console.log(error.target);
console.log(error.code);
},
false,
{
headers: {
"Authorization": "dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
}
}
);
});
我需要创建一个插件来刷新图片库,因为当你在Android设备上保存图片,此图片不会出现在图库中。此插件会更新图片库。
I needed to create a plugin to refresh the image gallery, because when you save an image on android device, this image does not appears on gallery. This plugin updates the image gallery.
refreshMedia.refresh(path); // Refresh the image gallery
插件: https://github.com/guinatal/refreshgallery
这篇关于Phonegap:将base64图像保存到图库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文