wstudiokiwi
wstudiokiwi

Reputation: 900

Save image into Gallery (Camera roll) Ionic 2

I save image from server to local path on device

downLoad() {
    this.http.downloadFile('http://example.com/files/files/image.jpg', {}, {}, 'image.jpg')
    .then(data => {
        console.log(data) ;
    })
    .catch(error => {

        console.log(error) ;

    });

}

But image save not in Photo Gallery. How it fix?

Upvotes: 0

Views: 5709

Answers (1)

Andreas Gassmann
Andreas Gassmann

Reputation: 6544

You can do that with this plugin: https://github.com/terikon/cordova-plugin-photo-library

After adding the plugin, you can save pictures like that:

var url = 'file:///...'; // file or remote URL. url can also be dataURL, but giving it a file path is much faster
var album = 'MyAppName';
cordova.plugins.photoLibrary.saveImage(url, album, function (libraryItem) {}, function (err) {});

Upvotes: 3

Related Questions