如何使用cordova Application.i将base64图像保存到设备库中。我将获得base64文本作为回复。
答案 0 :(得分:0)
您可以在此处找到http://ionicframework.com/docs/v2/native/base64-to%20gallery/
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=="
}
}
);
});