Search code examples
ioscordovagalleryfile-transfer

How to download picture with Phonegap Filetransfer to image gallery in iOS


This has been asked several times, but most of these questions are unanswered

I'm downloading a file like below, and it seems to work fine. However .. it does not show up in the iOS, ehm, gallery. That is, in the 'photos' application.

    var fileTransfer = new FileTransfer();
var encurl = encodeURI(url);
var filename = url.split('/').slice(-1)[0];
var filepath = "foo/"+filename;

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {
    var syspath = fileSystem.root.toURL() + '/' + filepath;
    var fileTransfer = new FileTransfer();
    fileTransfer.download(
        encurl,
        syspath,

        function (entry) {
            foo.debug("Download success "+syspath);
        },
        function (error) {
            foo.error("Download failed with error "+error.code+' '+syspath);
        }
    );
}, function (evt) {
    foo.error("Filesystem failed with error "+evt.target.error.code);

});

and the result is

[Log] Download success file:///var/mobile/Applications/68DE0AD9-FBD2-4D82-92C0-2B7634B218D5/Documents//foo/20141030-153810-editor.jpg (console-via-logger.js, line 173)

hurray. now, how do you open the download, using just your fingers, on ios ?


Solution

  • I would mark this as a duplicate of Phonegap - Save image from url into device photo gallery

    I was happy with the answer by M165437 and my comments. That answered my question.