将图像从phonegap应用程序保存到手机图库

时间:2017-01-16 12:38:57

标签: android jquery cordova jquery-mobile

我正在创建一个包含图片库的Phonegap Build应用。我想通过单击“保存”按钮将图像从Phonegap应用程序保存到移动图库。我尝试了几个选项并在StackOverflow上发布了一个问题

Saving Image From phonegap App to Mobile gallery

并尝试了其他方法从应用程序下载图像,但没有代码正常工作。

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function' <br>'(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=="
            }
        }
    );

});

0 个答案:

没有答案
相关问题